private static void OnPostprocessAllAssets(string[] _importedAssets, string[] _deletedAssets, string[] _movedAssets, string[] _movedFromAssetPaths)
 {
     DependencyGraphManager.AddDirtyAsset(_importedAssets);
     DependencyGraphManager.AddDeletedAsset(_deletedAssets);
     for (int i = 0; i < _movedAssets.Length; i++)
     {
         DependencyGraphManager.AddMovedAsset(_movedFromAssetPaths[i], _movedAssets[i]);
     }
 }
        private void OnGUI()
        {
            if (GUILayout.Button("Scan the project"))
            {
                DependencyGraphManager.ScanProject();
                DependencyGraphIOUtility.Save(DependencyGraphManager.AssetCollection.Values.ToList());
            }

            DependencyGraphAssetDrawer.DrawGraphForActiveObject();
        }
        private static void Update()
        {
            if (!DependencyGraphManager.IsDirty)
            {
                return;
            }

            AssetDatabase.SaveAssets();
            DependencyGraphManager.Update();
            DependencyGraphIOUtility.Save(DependencyGraphManager.AssetCollection.Values.ToList());
        }
        private static void PlayModeStateChangeHandler(PlayModeStateChange _playModeState)
        {
            switch (_playModeState)
            {
            case PlayModeStateChange.EnteredEditMode:
            case PlayModeStateChange.EnteredPlayMode:
                List <DependencyGraphAsset> collection = DependencyGraphIOUtility.Load();
                DependencyGraphManager.Init(collection);
                break;

            case PlayModeStateChange.ExitingEditMode:
            case PlayModeStateChange.ExitingPlayMode:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(_playModeState), _playModeState, null);
            }
        }
Beispiel #5
0
        internal override void Execute()
        {
            List <string> removedReferences = new List <string>();

            //Remove old references and dependencies
            if (DependencyGraphManager.AssetCollection.ContainsKey(m_path))
            {
                foreach (string dependency in DependencyGraphManager.AssetCollection[m_path].DependenciesPaths)
                {
                    if (DependencyGraphManager.AssetCollection.ContainsKey(dependency))
                    {
                        DependencyGraphManager.AssetCollection[dependency].RemoveReference(m_path);
                    }
                }

                foreach (string reference in DependencyGraphManager.AssetCollection[m_path].ReferencesPaths)
                {
                    if (DependencyGraphManager.AssetCollection.ContainsKey(reference))
                    {
                        DependencyGraphManager.AssetCollection[reference].RemoveDependency(m_path);
                        removedReferences.Add(reference);
                    }
                }
            }

            //Add new dependencies and references
            DependencyGraphManager.CreateNewItemIfNecessary(m_path);
            DependencyGraphManager.AssetCollection[m_path].UpdateDependencies();
            foreach (string dependency in DependencyGraphManager.AssetCollection[m_path].DependenciesPaths)
            {
                DependencyGraphManager.CreateNewItemIfNecessary(dependency);
                DependencyGraphManager.AssetCollection[dependency].AddReference(m_path);
            }

            foreach (string removedReference in removedReferences)
            {
                DependencyGraphManager.AssetCollection[removedReference].UpdateDependencies();
                if (DependencyGraphManager.AssetCollection[removedReference].DependenciesPaths.Contains(m_path))
                {
                    DependencyGraphManager.AssetCollection[m_path].AddReference(removedReference);
                }
            }
        }
Beispiel #6
0
        internal static void DrawGraphForActiveObject()
        {
            if (DependencyGraphManager.IsDirty)
            {
                return;
            }

            ClearData();
            UnityEngine.Object activeObject = Selection.activeObject;
            if (activeObject == null)
            {
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.HelpBox("No asset selected.", MessageType.Info);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();
                return;
            }

            DependencyGraphAsset graphAsset = DependencyGraphManager.GetSelectedAsset(AssetDatabase.GetAssetPath(activeObject));

            if (graphAsset == null)
            {
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                EditorGUILayout.HelpBox("Asset not analyzed.", MessageType.Info);
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();
                return;
            }

            m_scrollViewPosition = GUILayout.BeginScrollView(m_scrollViewPosition);
            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                {
                    //Draw references
                    foreach (string reference in graphAsset.ReferencesPaths)
                    {
                        DrawAsset(DependencyGraphManager.GetSelectedAsset(reference), AssetType.Reference);
                    }
                }
                GUILayout.EndVertical();
                GUILayout.Label("", GUILayout.MinWidth(KNOB_RADIUS * 8));
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                {
                    //Draw current asset
                    DrawAsset(graphAsset, AssetType.Selected);
                }
                GUILayout.EndVertical();
                GUILayout.Label("", GUILayout.MinWidth(KNOB_RADIUS * 8));
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical();
                {
                    //Draw dependencies
                    foreach (string dependency in graphAsset.DependenciesPaths)
                    {
                        DrawAsset(DependencyGraphManager.GetSelectedAsset(dependency), AssetType.Dependency);
                    }
                }
                GUILayout.EndVertical();
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();
            GUILayout.EndScrollView();
        }