public static IEnumerable <NPipeIImportable> EachSource(NPipeIImportable target) { NPipeIComposite targetComposite = target as NPipeIComposite; if (targetComposite != null) { NPipeIImportable[] sources = targetComposite.GetAllInputs(); foreach (NPipeIImportable item in sources) { yield return(item); } } }
public static IEnumerable <NPipeIImportable> EachSource(NPipeIImportable target, NPipeIImportable[] importables) { NPipeIComposite targetComposite = target as NPipeIComposite; if (targetComposite != null) { NPipeIImportable[] sources = targetComposite.GetAllInputs(); foreach (NPipeIImportable item in sources) { if (ArrayUtility.Contains(importables, item)) { yield return(item); } } } }
protected string DrawPipelineElements(string assetPath, NPipeIImportable importable, HashSet <NPipeIImportable> visited, bool hasNext, string nextAssetPath = "") { string thisAssetPath = AssetDatabase.GetAssetPath(importable as UnityEngine.Object); bool thisIsInContainer = thisAssetPath == assetPath; bool nextIsInContainer = nextAssetPath == assetPath; //==================================================================================================================== // Recursion for parent elements //==================================================================================================================== GUILayout.BeginVertical(); NPipeIComposite composite = importable as NPipeIComposite; bool isSource = true; bool parentIsInDifferentAsset = false; if (composite != null) { NPipeIImportable[] sources = composite.GetAllInputs(); GUILayout.BeginHorizontal(); if (sources != null) { foreach (NPipeIImportable source in sources) { isSource = false; if (source != null) { if (thisAssetPath != DrawPipelineElements(assetPath, source, visited, true, thisAssetPath)) { parentIsInDifferentAsset = true; } } else { GUILayout.Label("NULL !"); } } } GUILayout.EndHorizontal(); } //==================================================================================================================== // Background Color //==================================================================================================================== if ((!thisIsInContainer && parentIsInDifferentAsset) || (isSource && !thisIsInContainer && thisAssetPath != null)) { GUILayout.BeginHorizontal(); GUI.backgroundColor = GetColorForAssetPath(thisAssetPath); EditorGUILayout.ObjectField(AssetDatabase.LoadMainAssetAtPath(thisAssetPath), typeof(NPipeContainer), false); GUI.backgroundColor = Color.white; GUILayout.EndHorizontal(); } GUILayout.BeginHorizontal(); if (visited.Contains(importable)) { GUILayout.Label(importable.GetTypeName()); } else { visited.Add(importable); //==================================================================================================================== // Action Buttons //==================================================================================================================== if (!thisIsInContainer) { GUI.backgroundColor = GetColorForAssetPath(thisAssetPath); } else { GUI.backgroundColor = isMultiInstance ? thisContainerMultiColor : thisContainerColor; } //==================================================================================================================== // Delete Editiable //==================================================================================================================== if (editingImportable == importable && this.targets.Length < 2) { if (this.targets.Length < 2) { if (!confirmDeletion && GUILayout.Button("Delete")) { confirmDeletion = true; } else if (confirmDeletion && GUILayout.Button("Sure?")) { editingImportable = null; lastEditingImportable = null; Delete(assetPath, importable); AssetDatabase.SaveAssets(); } } } //==================================================================================================================== // Edit Editiable //==================================================================================================================== if (editingImportable == importable) { if (GUILayout.Button("Close", GUILayout.Width(40))) { editingImportable = null; lastEditingImportable = null; } } else { if (thisIsInContainer && GUILayout.Button("Edit", GUILayout.Width(40))) { editingImportable = importable; lastEditingImportable = importable; confirmDeletion = false; } } //==================================================================================================================== // Editable Label //==================================================================================================================== GUIStyle style = normalStyle; if (editingImportable == importable) { style = boldStyle; } string n = ((NPipeContainer)target).GetDisplayName(importable); GUILayout.Label(n, style); } GUILayout.EndHorizontal(); if (hasNext) { if (thisIsInContainer || nextIsInContainer) { DrawArrow(GUI.backgroundColor = isMultiInstance ? thisContainerMultiColor : thisContainerColor); } else if (nextAssetPath != thisAssetPath) { DrawArrow(GetColorForAssetPath(nextAssetPath)); } } GUI.backgroundColor = Color.white; GUILayout.EndVertical(); return(thisAssetPath); }