コード例 #1
0
        public override void OnPreTargetMembersGUI()
        {
            var skin           = InspectorEditor.Skin;
            var directory      = AssetDatabase.GUIDToAssetPath(RestoredAGXFile.DataDirectoryId);
            var directoryValid = directory.Length > 0 && AssetDatabase.IsValidFolder(directory);

            using (new GUILayout.HorizontalScope()) {
                EditorGUILayout.PrefixLabel(GUI.MakeLabel("Data directory"),
                                            skin.Label);

                var statusColor = directoryValid ?
                                  Color.Lerp(InspectorGUI.BackgroundColor, Color.green, EditorGUIUtility.isProSkin ? 0.8f : 0.2f) :
                                  Color.Lerp(Color.white, Color.red, EditorGUIUtility.isProSkin ? 0.8f : 0.2f);
                var prevColor = UnityEngine.GUI.backgroundColor;

                UnityEngine.GUI.backgroundColor = statusColor;
                EditorGUILayout.SelectableLabel(directory,
                                                skin.TextField,
                                                GUILayout.Height(EditorGUIUtility.singleLineHeight));
                UnityEngine.GUI.backgroundColor = prevColor;
                if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"),
                                     skin.Button,
                                     GUILayout.Width(28)))
                {
                    var newDirectory = EditorUtility.OpenFolderPanel("Prefab data directory", "Assets", "");
                    if (newDirectory.Length > 0)
                    {
                        var relPath = IO.Utils.MakeRelative(newDirectory, Application.dataPath).Replace('\\', '/');
                        if (AssetDatabase.IsValidFolder(relPath))
                        {
                            RestoredAGXFile.DataDirectoryId = AssetDatabase.AssetPathToGUID(relPath);
                            EditorUtility.SetDirty(RestoredAGXFile);
                        }
                    }
                }
            }

            AssemblyTool.OnObjectListsGUI(this);
        }
コード例 #2
0
        public override void OnPreTargetMembersGUI(GUISkin skin)
        {
            var directory      = AssetDatabase.GUIDToAssetPath(RestoredAGXFile.DataDirectoryId);
            var directoryValid = directory.Length > 0 && AssetDatabase.IsValidFolder(directory);

            using (new GUILayout.HorizontalScope()) {
                GUILayout.Label(GUI.MakeLabel("Data directory"), skin.label, GUILayout.Width(160));

                var statusColor = directoryValid ?
                                  Color.Lerp(Color.white, Color.green, 0.2f) :
                                  Color.Lerp(Color.white, Color.red, 0.2f);
                var prevColor = UnityEngine.GUI.backgroundColor;

                UnityEngine.GUI.backgroundColor = statusColor;
                GUILayout.TextField(directory, skin.textField);
                UnityEngine.GUI.backgroundColor = prevColor;
                if (GUILayout.Button(GUI.MakeLabel("...", false, "Open file panel"),
                                     skin.button,
                                     GUILayout.Width(28)))
                {
                    var newDirectory = EditorUtility.OpenFolderPanel("Prefab data directory", "Assets", "");
                    if (newDirectory.Length > 0)
                    {
                        var relPath = IO.Utils.MakeRelative(newDirectory, Application.dataPath).Replace('\\', '/');
                        if (AssetDatabase.IsValidFolder(relPath))
                        {
                            RestoredAGXFile.DataDirectoryId = AssetDatabase.AssetPathToGUID(relPath);
                            EditorUtility.SetDirty(RestoredAGXFile);
                        }
                    }
                }
            }

            GUI.Separator();

            AssemblyTool.OnObjectListsGUI(RestoredAGXFile, skin);
        }