コード例 #1
0
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();
            //base.serializedObject.Update();
            if (GUILayout.Button("Open in Shader Editor"))
            {
#if UNITY_2018_3_OR_NEWER
                ASEPackageManagerHelper.SetupLateShaderFunction(m_target);
#else
                AmplifyShaderEditorWindow.LoadShaderFunctionToASE(m_target, false);
#endif
            }
            //EditorGUILayout.Separator();
            //m_target.FunctionInfo = EditorGUILayout.TextArea( m_target.FunctionInfo );

            if (m_target.Description.Length > 0)
            {
                EditorGUILayout.HelpBox(m_target.Description, MessageType.Info);
            }
        }
コード例 #2
0
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();
            //base.serializedObject.Update();
            if (GUILayout.Button("Open in Shader Editor"))
            {
#if UNITY_2018_3_OR_NEWER
                ASEPackageManagerHelper.SetupLateShaderFunction(m_target);
#else
                AmplifyShaderEditorWindow.LoadShaderFunctionToASE(m_target, false);
#endif
            }
            //EditorGUILayout.Separator();
            //m_target.FunctionInfo = EditorGUILayout.TextArea( m_target.FunctionInfo );

            if (m_target.Description.Length > 0)
            {
                EditorGUILayout.HelpBox(m_target.Description, MessageType.Info);
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("Search Direct Dependencies"))
            {
                m_dependencies.Clear();
                string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_target));

                string[] allSFs = AssetDatabase.FindAssets("t:AmplifyShaderFunction", null);
                foreach (string guid1 in allSFs)
                {
                    string sfPath = AssetDatabase.GUIDToAssetPath(guid1);
                    bool   found  = SearchForGUID(guid, sfPath);
                    if (found)
                    {
                        //string n = Regex.Replace( sfPath, @"(\.\w+|[\w\d\/]+\/)", "" );
                        string n = Regex.Replace(sfPath, @"[\w\d\/]+\/", "");
                        m_dependencies.Add(new FunctionDependency(n, sfPath));
                    }
                }

                string[] allSHs = AssetDatabase.FindAssets("t:Shader", null);
                foreach (string guid1 in allSHs)
                {
                    string shPath = AssetDatabase.GUIDToAssetPath(guid1);
                    bool   found  = SearchForGUID(guid, shPath);
                    if (found)
                    {
                        string n = Regex.Replace(shPath, @"[\w\d\/]+\/", "");
                        m_dependencies.Add(new FunctionDependency(n, shPath));
                    }
                }
            }
            EditorGUILayout.Space();
            for (int i = 0; i < m_dependencies.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(m_dependencies[i].AssetName, "minibuttonleft"))
                {
                    SelectAtPath(m_dependencies[i].AssetPath);
                }
                if (GUILayout.Button("edit", "minibuttonright", GUILayout.Width(100)))
                {
                    if (m_dependencies[i].AssetName.EndsWith(".asset"))
                    {
                        var obj = AssetDatabase.LoadAssetAtPath <AmplifyShaderFunction>(m_dependencies[i].AssetPath);
                        AmplifyShaderEditorWindow.LoadShaderFunctionToASE(obj, false);
                    }
                    else
                    {
                        var obj = AssetDatabase.LoadAssetAtPath <Shader>(m_dependencies[i].AssetPath);
                        AmplifyShaderEditorWindow.ConvertShaderToASE(obj);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            if (m_dependencies.Count > 0)
            {
                List <string> assetPaths = new List <string>();
                for (int i = 0; i < m_dependencies.Count; i++)
                {
                    assetPaths.Add(m_dependencies[i].AssetPath);
                }

                if (GUILayout.Button("Open and Save All"))
                {
                    bool doit = EditorUtility.DisplayDialog("Open and Save All", "This will try to open all shader function and shaders that use this shader function and save them in quick succession, this may irreversibly break your files if something goes wrong. Are you sure you want to try?", "Yes, I'll take the risk", "No, I'll do it myself");
                    if (doit)
                    {
                        AmplifyShaderEditorWindow.LoadAndSaveList(assetPaths.ToArray());
                    }
                }
            }
        }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();
            //base.serializedObject.Update();
            if (GUILayout.Button("Open in Shader Editor"))
            {
#if UNITY_2018_3_OR_NEWER
                ASEPackageManagerHelper.SetupLateShaderFunction(m_target);
#else
                AmplifyShaderEditorWindow.LoadShaderFunctionToASE(m_target, false);
#endif
            }
            //EditorGUILayout.Separator();
            //m_target.FunctionInfo = EditorGUILayout.TextArea( m_target.FunctionInfo );

            if (m_target.Description.Length > 0)
            {
                EditorGUILayout.HelpBox(m_target.Description, MessageType.Info);
            }

            EditorGUILayout.Space();
            if (GUILayout.Button("Search Direct Dependencies"))
            {
                m_dependencies.Clear();
                string guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(m_target));

                string[] allSFs = AssetDatabase.FindAssets("t:AmplifyShaderFunction", null);
                foreach (string guid1 in allSFs)
                {
                    string sfPath = AssetDatabase.GUIDToAssetPath(guid1);
                    bool   found  = SearchForGUID(guid, sfPath);
                    if (found)
                    {
                        //string n = Regex.Replace( sfPath, @"(\.\w+|[\w\d\/]+\/)", "" );
                        string n = Regex.Replace(sfPath, @"[\w\d\/]+\/", "");
                        m_dependencies.Add(new FunctionDependency(n, sfPath));
                    }
                }

                string[] allSHs = AssetDatabase.FindAssets("t:Shader", null);
                foreach (string guid1 in allSHs)
                {
                    string shPath = AssetDatabase.GUIDToAssetPath(guid1);
                    bool   found  = SearchForGUID(guid, shPath);
                    if (found)
                    {
                        string n = Regex.Replace(shPath, @"[\w\d\/]+\/", "");
                        m_dependencies.Add(new FunctionDependency(n, shPath));
                    }
                }
            }
            EditorGUILayout.Space();
            for (int i = 0; i < m_dependencies.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button(m_dependencies[i].AssetName, "minibuttonleft"))
                {
                    SelectAtPath(m_dependencies[i].AssetPath);
                }
                if (GUILayout.Button("edit", "minibuttonright", GUILayout.Width(100)))
                {
                    if (m_dependencies[i].AssetName.EndsWith(".asset"))
                    {
                        var obj = AssetDatabase.LoadAssetAtPath <AmplifyShaderFunction>(m_dependencies[i].AssetPath);
                        AmplifyShaderEditorWindow.LoadShaderFunctionToASE(obj, false);
                    }
                    else
                    {
                        var obj = AssetDatabase.LoadAssetAtPath <Shader>(m_dependencies[i].AssetPath);
                        AmplifyShaderEditorWindow.ConvertShaderToASE(obj);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
        }