Ejemplo n.º 1
0
 public void OnEntityContextClick(IEnumerable <Object> entities, GenericMenu contextMenu)
 {
     if (entities.Count() == 1)
     {
         var single = entities.First();
         var type   = single.GetType();
         contextMenu.AddItem(new GUIContent("inspect type " + type.Name), false, () => api.ResetTargets(new[] { type }));
     }
 }
        public void RenderToolbar()
        {
            // entiy name field and buttons
            GUI.enabled = waitingForEntityName;
            if (waitingForEntityName)
            {
                RenderEntityCreationGUI();
            }
            GUI.enabled = true;

            // new graph button
            if (GUILayout.Button(newButtonContent, EditorStyles.toolbarButton))
            {
                api.ResetTargets(new object[] { });
            }

            // create entity button
            if (!waitingForEntityName)
            {
                if (GUILayout.Button(createEntityButtonContent, EditorStyles.toolbarButton))
                {
                    InitEntityCreation(Vector2.zero);
                }
            }

            // asset path selector
            pathButtonContent.text = "Path: " + assetPath;
            if (GUILayout.Button(pathButtonContent, EditorStyles.toolbarButton))
            {
                string absoluteAssetDir = Path.Combine(Application.dataPath, assetPath);
                string userSelectedPath = EditorUtility.OpenFolderPanel("Asset directory", absoluteAssetDir, "");
                if (BackendUtil.IsValidAssetDirectory(userSelectedPath))
                {
                    assetPath = userSelectedPath.RemovePrefix(Application.dataPath);
                    string prefsKey = Path.Combine(prefsKeyPath, typeof(T).Name);
                    EditorPrefs.SetString(prefsKey, assetPath);
                }
            }

            GUILayout.FlexibleSpace();
        }