Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit a6663d0

Browse files
committed
Added profile factor; renamed all tools to factories
1 parent cb0cfb6 commit a6663d0

11 files changed

+84
-32
lines changed

PostProcessing/Editor/PostProcessProfileEditor.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System;
2-
using System.Linq.Expressions;
31
using UnityEngine.Experimental.PostProcessing;
42

53
namespace UnityEditor.Experimental.PostProcessing

PostProcessing/Editor/PostProcessVolumeEditor.cs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -81,32 +81,7 @@ public override void OnInspectorGUI()
8181
// scene file. If the user isn't a scene, put them in root instead.
8282
var targetName = m_Target.name;
8383
var scene = m_Target.gameObject.scene;
84-
var path = string.Empty;
85-
86-
if (string.IsNullOrEmpty(scene.path))
87-
{
88-
path = "Assets/";
89-
}
90-
else
91-
{
92-
var scenePath = Path.GetDirectoryName(scene.path);
93-
var extPath = scene.name + "_Profiles";
94-
var profilePath = scenePath + "/" + extPath;
95-
96-
if (!AssetDatabase.IsValidFolder(profilePath))
97-
AssetDatabase.CreateFolder(scenePath, extPath);
98-
99-
path = profilePath + "/";
100-
}
101-
102-
path += targetName + " Profile.asset";
103-
path = AssetDatabase.GenerateUniqueAssetPath(path);
104-
105-
var asset = CreateInstance<PostProcessProfile>();
106-
AssetDatabase.CreateAsset(asset, path);
107-
AssetDatabase.SaveAssets();
108-
AssetDatabase.Refresh();
109-
84+
var asset = ProfileFactory.CreatePostProcessProfile(scene, targetName);
11085
m_Profile.objectReferenceValue = asset;
11186
assetHasChanged = true;
11287
}

PostProcessing/Editor/Tools/CubeLutAssetGenerator.cs renamed to PostProcessing/Editor/Tools/CubeLutAssetFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace UnityEditor.Experimental.PostProcessing
88
{
99
// CUBE lut specs:
1010
// http://wwwimages.adobe.com/content/dam/Adobe/en/products/speedgrade/cc/pdfs/cube-lut-specification-1.0.pdf
11-
static class CubeLutAssetGenerator
11+
static class CubeLutAssetFactory
1212
{
1313
const int kVersion = 1;
1414
const int kSize = 33;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using UnityEngine;
2+
using UnityEditor.ProjectWindowCallback;
3+
using System.IO;
4+
using UnityEngine.SceneManagement;
5+
using UnityEngine.Experimental.PostProcessing;
6+
7+
namespace UnityEditor.Experimental.PostProcessing
8+
{
9+
class ProfileFactory
10+
{
11+
[MenuItem("Assets/Create/Post-processing Profile", priority = 201)]
12+
static void CreatePostProcessProfile()
13+
{
14+
var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon");
15+
ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance<DoCreatePostProcessProfile>(), "New Post-processing Profile.asset", icon, null);
16+
}
17+
18+
internal static PostProcessProfile CreatePostProcessProfileAtPath(string path)
19+
{
20+
var profile = ScriptableObject.CreateInstance<PostProcessProfile>();
21+
profile.name = Path.GetFileName(path);
22+
AssetDatabase.CreateAsset(profile, path);
23+
AssetDatabase.SaveAssets();
24+
AssetDatabase.Refresh();
25+
return profile;
26+
}
27+
28+
internal static PostProcessProfile CreatePostProcessProfile(Scene scene, string targetName)
29+
{
30+
var path = string.Empty;
31+
32+
if (string.IsNullOrEmpty(scene.path))
33+
{
34+
path = "Assets/";
35+
}
36+
else
37+
{
38+
var scenePath = Path.GetDirectoryName(scene.path);
39+
var extPath = scene.name + "_Profiles";
40+
var profilePath = scenePath + "/" + extPath;
41+
42+
if (!AssetDatabase.IsValidFolder(profilePath))
43+
AssetDatabase.CreateFolder(scenePath, extPath);
44+
45+
path = profilePath + "/";
46+
}
47+
48+
path += targetName + " Profile.asset";
49+
path = AssetDatabase.GenerateUniqueAssetPath(path);
50+
51+
var profile = ScriptableObject.CreateInstance<PostProcessProfile>();
52+
AssetDatabase.CreateAsset(profile, path);
53+
AssetDatabase.SaveAssets();
54+
AssetDatabase.Refresh();
55+
return profile;
56+
}
57+
}
58+
59+
class DoCreatePostProcessProfile : EndNameEditAction
60+
{
61+
public override void Action(int instanceId, string pathName, string resourceFile)
62+
{
63+
var profile = ProfileFactory.CreatePostProcessProfileAtPath(pathName);
64+
ProjectWindowUtil.ShowCreatedAsset(profile);
65+
}
66+
}
67+
}

PostProcessing/Editor/Tools/ProfileFactory.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PostProcessing/Editor/Tools/ResourceAssetGenerator.cs renamed to PostProcessing/Editor/Tools/ResourceAssetFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace UnityEditor.Experimental.PostProcessing
55
{
6-
static class ResourceAssetGenerator
6+
static class ResourceAssetFactory
77
{
88
#if POSTFX_DEBUG_MENUS
99
[MenuItem("Tools/Post-processing/Create Resources Asset")]

PostProcessing/Editor/Tools/VolumeCreator.cs renamed to PostProcessing/Editor/Tools/VolumeFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace UnityEditor.Experimental.PostProcessing
55
{
6-
public static class VolumeCreator
6+
public static class VolumeFactory
77
{
88
[MenuItem("GameObject/3D Object/Post-process Volume")]
99
static void CreateVolume()

0 commit comments

Comments
 (0)