public override void OnInspectorGUI() { // try to re-open similar importable to the last one if (editingImportable == null && lastEditingImportable != null) { string warningMessage = ""; NPipeIImportable[] imp = NPipelineUtils.GetSimiliarPipes(new UnityEngine.Object[] { this.target }, this.target as NPipeContainer, lastEditingImportable, out warningMessage); if (imp.Length != 1) { lastEditingImportable = null; } else { editingImportable = imp[0]; } } isMultiInstance = targets.Length > 1; // main inspectorr DrawPipelineElements(); }
private void drawPipeEditor(string assetPath) { NPipeIImportable importable = editingImportable as NPipeIImportable; if (importable == null) { return; } //==================================================================================================================== // Selected Importable(s) Label //==================================================================================================================== NPipeIImportable[] multiInstanceEditingImportables = null; if (isMultiInstance) { string warningMessage = ""; multiInstanceEditingImportables = NPipelineUtils.GetSimiliarPipes(this.targets, this.target as NPipeContainer, this.editingImportable as NPipeIImportable, out warningMessage); GUILayout.Space(10f); GUILayout.Label(string.Format("Selected: {0} ( {1} instances )", editingImportable.GetTypeName(), multiInstanceEditingImportables.Length), EditorStyles.boldLabel); if (warningMessage.Length > 0) { // GUI.backgroundColor = Color.yellow; GUILayout.Label("WARNING: " + warningMessage); } } else { GUILayout.Space(10f); GUILayout.Label("Selected: " + editingImportable.GetTypeName(), EditorStyles.boldLabel); } //==================================================================================================================== // Selected Importable(s) Editor Inspectors //==================================================================================================================== NPipeIEditable editable = editingImportable as NPipeIEditable; if (editable != null) { GUILayout.Label("Edit:"); if (isMultiInstance) { editable.DrawMultiInstanceEditor(~NPipeEditFlags.TOOLS, NPipelineUtils.GetUntypedFactories <NPipeIImportable>(multiInstanceEditingImportables)); } else { editable.DrawInspector(~NPipeEditFlags.TOOLS); } } GUILayout.Space(10f); GUILayout.BeginVertical(); GUILayout.Space(10f); //==================================================================================================================== // append other pipes //==================================================================================================================== if (!isMultiInstance) { GUILayout.BeginHorizontal(); List <System.Type> allTypes = new List <System.Type>(); List <NPipeAppendableAttribute> allAttrsa = new List <NPipeAppendableAttribute>(); List <string> allLabels = new List <string>(); foreach (Type factoryType in NPipeReflectionUtil.GetAllTypesWithAttribute(typeof(NPipeAppendableAttribute))) { NPipeAppendableAttribute attr = (NPipeAppendableAttribute)factoryType.GetCustomAttributes(typeof(NPipeAppendableAttribute), true)[0]; if (!attr.sourceType.IsAssignableFrom(importable.GetType())) { continue; } allTypes.Add(factoryType); allAttrsa.Add(attr); allLabels.Add(attr.name); } if (allTypes.Count > 0) { GUILayout.Label("Append: "); selectedAppendIndex = EditorGUILayout.Popup(selectedAppendIndex, allLabels.ToArray()); if (selectedAppendIndex >= 0 && selectedAppendIndex < allTypes.Count) { NPipeAppendableAttribute pipe = allAttrsa[selectedAppendIndex]; NPipeIComposite newImportable = null; if (pipe.attached && GUILayout.Button("This Container")) { newImportable = NPipelineUtils.CreateAttachedPipe(assetPath, allTypes[selectedAppendIndex], importable) as NPipeIComposite; editingImportable = newImportable; lastEditingImportable = newImportable; confirmDeletion = false; } if (pipe.separate && GUILayout.Button("New Container")) { newImportable = NPipelineUtils.CreateSeparatedPipe(assetPath, allTypes[selectedAppendIndex], importable) as NPipeIComposite; } if (newImportable != null) { AssetDatabase.SaveAssets(); UnityEditor.Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GetAssetPath(newImportable as UnityEngine.Object)); } } else { selectedAppendIndex = 0; } } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }