You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.3 KiB

  1. using UnityEngine;
  2. using UnityEngine.PostProcessing;
  3. using UnityEditor.ProjectWindowCallback;
  4. using System.IO;
  5. namespace UnityEditor.PostProcessing
  6. {
  7. public class PostProcessingFactory
  8. {
  9. [MenuItem("Assets/Create/Post-Processing Profile", priority = 201)]
  10. static void MenuCreatePostProcessingProfile()
  11. {
  12. var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
  13. ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreatePostProcessingProfile>(), "New Post-Processing Profile.asset", icon, null);
  14. }
  15. internal static PostProcessingProfile CreatePostProcessingProfileAtPath(string path)
  16. {
  17. var profile = ScriptableObject.CreateInstance<PostProcessingProfile>();
  18. profile.name = Path.GetFileName(path);
  19. profile.fog.enabled = true;
  20. AssetDatabase.CreateAsset(profile, path);
  21. return profile;
  22. }
  23. }
  24. class DoCreatePostProcessingProfile : EndNameEditAction
  25. {
  26. public override void Action(int instanceId, string pathName, string resourceFile)
  27. {
  28. PostProcessingProfile profile = PostProcessingFactory.CreatePostProcessingProfileAtPath(pathName);
  29. ProjectWindowUtil.ShowCreatedAsset(profile);
  30. }
  31. }
  32. }