Ejemplo n.º 1
0
 public override void Initialize(Model.NodeData data)
 {
     m_path  = new SerializableMultiTargetString();
     m_style = AssertionStyle.AllowOnlyAssetsUnderAssertionPath;
     data.AddDefaultInputPoint();
     data.AddDefaultOutputPoint();
 }
Ejemplo n.º 2
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Assert Unwanted Assets In Bundle: Checks if unwanted assets are included in bundle configurations.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            var newValue = (AssertionStyle)EditorGUILayout.EnumPopup("Assertion Style", m_style);

            if (newValue != m_style)
            {
                using (new RecordUndoScope("Change Assertion Style", node, true)) {
                    m_style = newValue;
                    onValueChanged();
                }
            }

            GUILayout.Space(4f);

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_path.ContainsValueOf(editor.CurrentEditingGroup), (bool b) => {
                    using (new RecordUndoScope("Remove Target Load Path Settings", node, true)) {
                        if (b)
                        {
                            m_path[editor.CurrentEditingGroup] = m_path.DefaultValue;
                        }
                        else
                        {
                            m_path.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    var path = m_path[editor.CurrentEditingGroup];
                    EditorGUILayout.LabelField("Assertion Path:");

                    string newLoadPath = null;

                    newLoadPath = editor.DrawFolderSelector(Model.Settings.Path.ASSETS_PATH, "Select Asset Folder",
                                                            path,
                                                            FileUtility.PathCombine(Model.Settings.Path.ASSETS_PATH, path),
                                                            (string folderSelected) => {
                        var dataPath = Application.dataPath;
                        if (dataPath == folderSelected)
                        {
                            folderSelected = string.Empty;
                        }
                        else
                        {
                            var index = folderSelected.IndexOf(dataPath);
                            if (index >= 0)
                            {
                                folderSelected = folderSelected.Substring(dataPath.Length + index);
                                if (folderSelected.IndexOf('/') == 0)
                                {
                                    folderSelected = folderSelected.Substring(1);
                                }
                            }
                        }
                        return(folderSelected);
                    }
                                                            );

                    if (newLoadPath != path)
                    {
                        using (new RecordUndoScope("Path Change", node, true)){
                            m_path[editor.CurrentEditingGroup] = newLoadPath;
                            onValueChanged();
                        }
                    }

                    var  dirPath   = Path.Combine(Model.Settings.Path.ASSETS_PATH, newLoadPath);
                    bool dirExists = Directory.Exists(dirPath);

                    GUILayout.Space(10f);

                    using (new EditorGUILayout.HorizontalScope()) {
                        using (new EditorGUI.DisabledScope(string.IsNullOrEmpty(newLoadPath) || !dirExists))
                        {
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("Highlight in Project Window", GUILayout.Width(180f)))
                            {
                                // trailing is "/" not good for LoadMainAssetAtPath
                                if (dirPath[dirPath.Length - 1] == '/')
                                {
                                    dirPath = dirPath.Substring(0, dirPath.Length - 1);
                                }
                                var obj = AssetDatabase.LoadMainAssetAtPath(dirPath);
                                EditorGUIUtility.PingObject(obj);
                            }
                        }
                    }
                }
            }
        }