blob: 5fa1424fa40a74e4df9632b3fa999319390c29d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// Amplify Shader Editor - Visual Shader Editing Tool
// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
using UnityEngine;
using UnityEditor;
using UnityEditor.ProjectWindowCallback;
using System.IO;
namespace AmplifyShaderEditor
{
public class DoCreateStandardShader : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
string shaderName = Path.GetFileName( uniquePath );
if( IOUtils.AllOpenedWindows.Count > 0 )
{
EditorWindow openedWindow = AmplifyShaderEditorWindow.GetWindow<AmplifyShaderEditorWindow>();
AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.CreateTab();
WindowHelper.AddTab( openedWindow, currentWindow );
UIUtils.CurrentWindow = currentWindow;
}
else
{
AmplifyShaderEditorWindow currentWindow = AmplifyShaderEditorWindow.OpenWindow( shaderName, UIUtils.ShaderIcon );
UIUtils.CurrentWindow = currentWindow;
}
Shader shader = UIUtils.CreateNewEmpty( uniquePath, shaderName );
ProjectWindowUtil.ShowCreatedAsset( shader );
}
}
public class DoCreateTemplateShader : EndNameEditAction
{
public override void Action( int instanceId, string pathName, string resourceFile )
{
string uniquePath = AssetDatabase.GenerateUniqueAssetPath( pathName );
string shaderName = Path.GetFileName( uniquePath );
if( !string.IsNullOrEmpty( UIUtils.NewTemplateGUID ) )
{
Shader shader = AmplifyShaderEditorWindow.CreateNewTemplateShader( UIUtils.NewTemplateGUID, uniquePath, shaderName );
ProjectWindowUtil.ShowCreatedAsset( shader );
}
}
}
}
|