summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-23 13:08:43 +0800
committerchai <chaifix@163.com>2020-10-23 13:08:43 +0800
commitb82da95b5181ac8bbae38efb13e950d5e88a4caa (patch)
tree48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs')
-rw-r--r--Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs91
1 files changed, 91 insertions, 0 deletions
diff --git a/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs
new file mode 100644
index 00000000..e405e2e2
--- /dev/null
+++ b/Assets/ThirdParty/AmplifyShaderEditor/Plugins/Editor/Menu/ShaderLibrary.cs
@@ -0,0 +1,91 @@
+// Amplify Shader Editor - Visual Shader Editing Tool
+// Copyright (c) Amplify Creations, Lda <info@amplify.pt>
+
+using UnityEditor;
+using System.Collections.Generic;
+using System;
+using UnityEngine;
+
+namespace AmplifyShaderEditor
+{
+ [Serializable]
+ public class ShaderLibrary : EditorWindow
+ {
+ private const string SHADER_LIB_FILE = "/AmplifyShaderEditor/Resources/ShaderLibrary/ShaderLibrary.txt";
+ private bool m_init = false;
+ private Vector2 m_scrollPos = new Vector2();
+ [SerializeField]
+ private List<string> m_shaders = new List<string>();
+ void Init()
+ {
+ m_init = true;
+ string list = IOUtils.LoadTextFileFromDisk( Application.dataPath + SHADER_LIB_FILE );
+ if ( String.IsNullOrEmpty( list ) )
+ return;
+
+ string[] listArr = list.Split( IOUtils.FIELD_SEPARATOR );
+ for ( int i = 0; i < listArr.Length; i++ )
+ {
+ m_shaders.Add( listArr[ i ] );
+ }
+
+ UIUtils.MainSkin.customStyles[ 10 ].active.background = Texture2D.whiteTexture;
+
+ UIUtils.MainSkin.customStyles[ 6 ].fixedHeight = UIUtils.MainSkin.customStyles[ 6 ].normal.background.height;
+ UIUtils.MainSkin.customStyles[ 6 ].fixedWidth = UIUtils.MainSkin.customStyles[ 6 ].normal.background.width;
+
+ UIUtils.MainSkin.customStyles[ 7 ].fixedHeight = UIUtils.MainSkin.customStyles[ 7 ].normal.background.height;
+ UIUtils.MainSkin.customStyles[ 7 ].fixedWidth = UIUtils.MainSkin.customStyles[ 7 ].normal.background.width;
+
+ UIUtils.MainSkin.customStyles[ 8 ].fixedHeight = UIUtils.MainSkin.customStyles[ 8 ].normal.background.height;
+ UIUtils.MainSkin.customStyles[ 8 ].fixedWidth = UIUtils.MainSkin.customStyles[ 8 ].normal.background.width;
+
+ UIUtils.MainSkin.customStyles[ 9 ].fixedHeight = UIUtils.MainSkin.customStyles[ 9 ].normal.background.height;
+ UIUtils.MainSkin.customStyles[ 9 ].fixedWidth = UIUtils.MainSkin.customStyles[ 9 ].normal.background.width;
+
+ }
+
+ void OnGUI()
+ {
+ if ( !m_init )
+ {
+ Init();
+ }
+
+ Rect availableArea = position;
+
+ availableArea.y = 100f;
+ availableArea.x = 0.05f * availableArea.width;
+ availableArea.height *= 0.5f;
+ availableArea.width *= 0.9f;
+ EditorGUILayout.BeginVertical();
+ {
+ EditorGUILayout.LabelField( "Shader Library", UIUtils.MainSkin.customStyles[ 5 ] );
+ GUILayout.Space( 10 );
+ EditorGUILayout.BeginHorizontal();
+ {
+ GUILayout.Space( 0.05f * position.width );
+ GUILayout.Button( string.Empty, UIUtils.MainSkin.customStyles[ 8 ] );
+ GUILayout.Button( string.Empty, UIUtils.MainSkin.customStyles[ 9 ] );
+ GUILayout.Space( 0.8f*position.width );
+ GUILayout.Button( string.Empty, UIUtils.MainSkin.customStyles[ 7 ] );
+ GUILayout.Button( string.Empty, UIUtils.MainSkin.customStyles[ 6 ] );
+ }
+ EditorGUILayout.EndHorizontal();
+
+ GUILayout.BeginArea( availableArea );
+ m_scrollPos = EditorGUILayout.BeginScrollView( m_scrollPos, UIUtils.MainSkin.box );
+ {
+ for ( int i = 0; i < m_shaders.Count; i++ )
+ {
+ GUILayout.Button( m_shaders[ i ], UIUtils.MainSkin.customStyles[ 10 ] );
+ }
+ }
+ EditorGUILayout.EndScrollView();
+ GUILayout.EndArea();
+ }
+ EditorGUILayout.EndVertical();
+
+ }
+ }
+}