Skip to content

Commit

Permalink
support hierarchy in shader template pull-down menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Dec 29, 2017
1 parent 730b274 commit e3d1a6a
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions Assets/uShaderTemplate/Editor/Scripts/Common.cs
Expand Up @@ -36,6 +36,7 @@ public static class Setting
public const string menuPlace = "Shader/uShaderTemplate/";
public const string defaultConstants = "uShaderTemplate/Default Constants";
public const string templateDirectoryPath = "ShaderTemplates";
public const string templateFileExtension = ".txt";
}

}
Expand Down
13 changes: 8 additions & 5 deletions Assets/uShaderTemplate/Editor/Scripts/ShaderTemplateSelector.cs
Expand Up @@ -45,11 +45,14 @@ public ShaderTemplateSelector(SerializedProperty prop)

var paths = Utils.GetShaderTemplatePathList();
foreach (var path in paths) {
if (Path.GetExtension(path) == ".txt") {
var name = Path.GetFileNameWithoutExtension(path);
if (Path.GetExtension(path) == Common.Setting.templateFileExtension) {
var index = path.IndexOf(Common.Setting.templateDirectoryPath);
var name = path
.Substring(index + Common.Setting.templateDirectoryPath.Length + 1)
.Replace(Common.Setting.templateFileExtension, "");
var info = new TemplateInfo() {
name = name,
path = path
path = path,
};
list_.Add(info);
}
Expand All @@ -69,8 +72,8 @@ public void Draw()
var selected = list_[selectedIndex];

var openButtonStyle = EditorStyles.miniButton;
openButtonStyle.fixedWidth = 40;
if (GUILayout.Button("Open", openButtonStyle)) {
openButtonStyle.fixedWidth = 36;
if (GUILayout.Button("Edit", openButtonStyle)) {
var asset = AssetDatabase.LoadAssetAtPath(selected.path, typeof(Object));
AssetDatabase.OpenAsset(asset);
}
Expand Down
Binary file modified Assets/uShaderTemplate/Examples/Editor/Generators/Surface.asset
Binary file not shown.
Binary file modified Assets/uShaderTemplate/Examples/Editor/Generators/VertFrag.asset
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ProjectSettings/ProjectVersion.txt
@@ -1 +1 @@
m_EditorVersion: 2017.1.0b6
m_EditorVersion: 2017.3.0f3

0 comments on commit e3d1a6a

Please sign in to comment.