// Init turns the inspection target objects into root entities of the graph
        // we assume the two sets to be identical, so we're just pass them through
        // and initialize the toolbar
        public virtual IEnumerable <T> Init(object target)
        {
            if (target != null)
            {
                toolbar.SetAssetPath(BackendUtil.GetAssetDirectory(target as Object));
            }

            return((target is T) ? new T[] { target as T } : new T[0]);
        }
        // create entity asset at the given path
        void CreateEntityAsset()
        {
            var relativeAssetDirectory = "Assets" + assetPath;
            var path = System.IO.Path.Combine(relativeAssetDirectory, entityName + ".asset");

            path = AssetDatabase.GenerateUniqueAssetPath(path);

            T entity = BackendUtil.CreateAssetOfType <T>(path);

            api.AddEntity(entity, createEntityPosition);
        }
        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();
        }
 // GetContent is a utility method that returns name, icon, toolip for the given entity
 // if possible
 public virtual GUIContent GetContent(T entity)
 {
     return(BackendUtil.GetContent(entity));
 }
 // OnGUI is responible for rendering any backend GUI, like controls or a toolbar
 // returns the rect that will be used for graph drawing
 // we draw no controls, so the whole space can be used for the graph
 public virtual Rect OnGUI()
 {
     return(BackendUtil.GetMaxRect());
 }
 // OnGUI is responible for rendering any backend GUI, like controls or a toolbar
 // returns the rect that will be used for graph drawing
 public virtual Rect OnGUI()
 {
     toolbar.OnGUI();
     return(BackendUtil.GetMaxRect());
 }