/// <summary>
        /// Before a DataSetAsset is deleted, unload its Entities to clean up any scene proxies.
        /// </summary>
        /// <param name="assetPath"></param>
        /// <param name="rao"></param>
        /// <returns></returns>
        public static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions rao)
        {
            const AssetDeleteResult Result = AssetDeleteResult.DidNotDelete;

            var dataSet = AssetDatabase.LoadAssetAtPath <DataSetAsset>(assetPath);

            if (dataSet == null)
            {
                return(Result);
            }

            // TODO: Refactor and fix this monstrosity

            var wasDataListWindowOpen = DataListWindow.IsOpen;
            var window = DataListWindow.GetInstance();
            var guid   = AssetDatabase.AssetPathToGUID(assetPath);

            if (!window.IsDataSetOpen(guid))
            {
                return(Result);
            }

            window.RemoveDataSet(guid);

            if (!wasDataListWindowOpen)
            {
                window.Close();
            }

            return(Result);
        }
예제 #2
0
        protected override void DoubleClickedItem(int id)
        {
            base.DoubleClickedItem(id);

            // If the user double clicked a DataSet, then make it active.
            if (this.dataSetTreeIds.Contains(id))
            {
                DataListWindow.GetInstance().SetActiveDataSet(this.idToDataMap[id]);
            }
            else if (this.idToDataMap[id] is TransformData)
            {
                if (SceneView.lastActiveSceneView == null)
                {
                    Debug.LogWarning("SceneView.lastActiveSceneView is null. Click in the Scene view to fix this.");
                    return;
                }

                // If the user double clicked a TransformData, navigate to its scene proxy.
                var transformData = this.idToDataMap[id] as TransformData;
                var sceneProxy    = this.getSceneProxy(transformData.DataSetGuid, transformData.Name);

                if (sceneProxy == null)
                {
                    return;
                }

                SceneView.lastActiveSceneView.FrameSelected();
            }
        }
예제 #3
0
        void OnGUI()
        {
            if (_styles == null)
            {
                _styles = new Styles();
            }

            // Search bar.
            EditorGUILayout.BeginHorizontal(GUI.skin.FindStyle("Toolbar"));
            this.searchString = EditorGUILayout.TextField(this.searchString, GUI.skin.FindStyle("ToolbarSeachTextField"));
            if (GUILayout.Button(string.Empty, GUI.skin.FindStyle("ToolbarSeachCancelButton")))
            {
                // Remove focus if cleared
                this.searchString = string.Empty;
                GUI.FocusControl(null);
            }

            EditorGUILayout.EndHorizontal();

            this.scrollPos = EditorGUILayout.BeginScrollView(this.scrollPos, GUILayout.Width(this.position.width), GUILayout.Height(this.position.height));

            foreach (var type in this.selectableTypes)
            {
                if (type == typeof(DataSet))
                {
                    continue;
                }

                // Filter out results that don't contain search string.
                if (type.Name.IndexOf(this.searchString, 0, StringComparison.CurrentCultureIgnoreCase) == -1)
                {
                    continue;
                }

                if (!GUILayout.Button(type.Name, _styles.componentButton))
                {
                    continue;
                }

                if (DataListWindow.GetInstance().ActiveDataSet == null)
                {
                    EditorUtility.DisplayDialog("Error", "Can't create an Entity without an active DataSet.", "OK", "");
                    return;
                }

                this.onTypeSelected(type);

                if (this.closeAfterSelection)
                {
                    this.Close();
                }
            }

            EditorGUILayout.EndScrollView();
        }
예제 #4
0
        protected override void ContextClickedItem(int id)
        {
            // For the time being, we only care about right clicking on the DataSet, not its children.
            // So, don't open the menu if the user didn't right click on a DataSet.
            var selectedDataSets = from treeId in this.GetSelection()
                                   where this.dataSetTreeIds.Contains(treeId)
                                   select this.idToDataMap[treeId] as DataSet;

            var clickedDataSet = this.idToDataMap[id] as DataSet;

            if (clickedDataSet == null)
            {
                return;
            }

            DataListWindow.GetInstance()
            .MakeShowItemContextMenuDelegate()(clickedDataSet, selectedDataSets.ToList());
        }
 private static void OnAddEntity()
 {
     AddEntityWindow.Create(typeof(Data), false, type => DataListWindow.GetInstance().AddEntity(type));
 }