private void OnAddCallback(ReorderableList list) { UViewEditorUtils.ContextCreateView(); }
private void DrawViewGUI() { EditorGUILayout.LabelField("Configuration", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_propertyAutoSetup); EditorGUILayout.PropertyField(_propertyDontDestroyOnLoad); EditorGUILayout.PropertyField(_propertyDebug); EditorGUILayout.PropertyField(_propertyViewParent); string[] viewNames = UViewEditorUtils.GetViewNames(_propertyViewAssets, false); string[] viewNamesShort = UViewEditorUtils.GetViewNames(_propertyViewAssets, true); int startLocationIndex = System.Array.IndexOf <string>(viewNames, _propertyStartingLocation.stringValue); startLocationIndex = EditorGUILayout.Popup("Start Location", startLocationIndex, viewNamesShort); _propertyStartingLocation.stringValue = startLocationIndex == -1 ? "" : viewNames[startLocationIndex]; EditorGUILayout.Space(); EditorGUILayout.Space(); bool locked = EditorApplication.isCompiling && EditorPrefs.HasKey(UViewEditorUtils.KEY_SCRIPT_PATH); EditorGUI.BeginDisabledGroup(locked); _viewList.requiresRebuild = false; _viewList.UpdateLoadedViews(); _viewList.DoLayoutList(); if (_viewList.requiresRebuild && !_attemptedRebuild) { Debug.LogWarning("Views missing or changed, rebuilding..."); UViewEditorUtils.Rebuild(_propertyViewAssets); _viewList.requiresRebuild = false; _attemptedRebuild = true; } EditorGUILayout.BeginVertical(EditorStyles.helpBox); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); EditorGUILayout.LabelField("Add Existing", GUILayout.Width(80)); GameObject viewGameObject = EditorGUILayout.ObjectField(null, typeof(GameObject), false) as GameObject; if (viewGameObject != null) { AbstractView view = viewGameObject.GetComponent <AbstractView>(); if (view != null) { // TODO: check this view isn't already in the list _showInvalidWarning = false; int index = _propertyViewAssets.arraySize; _propertyViewAssets.InsertArrayElementAtIndex(index); UViewEditorUtils.CreateViewAsset(_propertyViewAssets.GetArrayElementAtIndex(index), view as AbstractView); } else { _showInvalidWarning = true; } } if (GUILayout.Button("Create New", GUILayout.Width(100))) { UViewEditorUtils.ContextCreateView(); } GUILayout.Space(5); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(5); if (GUILayout.Button("Rebuild List", GUILayout.Width(110))) { _attemptedRebuild = false; UViewEditorUtils.Rebuild(_propertyViewAssets); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.EndVertical(); EditorGUI.EndDisabledGroup(); if (_showInvalidWarning) { EditorGUILayout.HelpBox("Asset must have an AbstractView component attached", MessageType.Warning); } EditorGUILayout.Space(); if (locked) { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.HelpBox("Creating View...", MessageType.Info); } }