internal static void CreateNewItemIfNecessary(string _path) { if (!AssetCollection.ContainsKey(_path)) { AssetCollection[_path] = new DependencyGraphAsset(_path); } }
private static void DrawAsset(DependencyGraphAsset _graphAsset, AssetType _assetType) { if (_graphAsset == null) { return; } GUILayout.FlexibleSpace(); GUILayout.Label("", ""); DrawRectangleBackground(_assetType); DrawAssetInformation(_graphAsset); DrawKnobs(_graphAsset, _assetType); DrawConnections(); GUILayout.Label(""); GUILayout.FlexibleSpace(); }
private static void DrawAssetInformation(DependencyGraphAsset _graphAsset) { GUILayout.BeginHorizontal(); { GUILayout.Label("", GUILayout.MinWidth(KNOB_RADIUS)); GUILayout.BeginVertical(); { UnityEngine.Object myAsset = AssetDatabase.LoadAssetAtPath <UnityEngine.Object>(_graphAsset.Path); EditorGUILayout.ObjectField(myAsset, typeof(UnityEngine.Object), false); if (GUILayout.Button("Select")) { Selection.activeObject = myAsset; EditorUtility.FocusProjectWindow(); } } GUILayout.EndVertical(); GUILayout.Label("", GUILayout.MinWidth(KNOB_RADIUS)); } GUILayout.EndHorizontal(); }
private static void DrawKnobs(DependencyGraphAsset _graphAsset, AssetType _assetType) { Rect lastRect = GUILayoutUtility.GetLastRect(); Vector2 knobCenter = new Vector2(lastRect.x, lastRect.y); knobCenter.y += lastRect.height / 2; //Left knob if (_assetType == AssetType.Selected || _assetType == AssetType.Dependency) { DrawKnob(knobCenter, _graphAsset.ReferencesPaths.Count); SaveKnobToDrawConnections(knobCenter, _assetType, Knob.Left); } //Right knob if (_assetType == AssetType.Reference || _assetType == AssetType.Selected) { knobCenter.x += lastRect.width; DrawKnob(knobCenter, _graphAsset.DependenciesPaths.Count); SaveKnobToDrawConnections(knobCenter, _assetType, Knob.Right); } }
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(); }