void SetupLists() { _lists = new Dictionary <string, Editor_List>(); _asoLists = new Dictionary <string, Editor_ASOList>(); //Create new lists for each array property #region Create Lists from Properties SerializedProperty properties = serializedObject.GetIterator(); while (properties.NextVisible(true)) { if (properties.isArray && properties.propertyType != SerializedPropertyType.String) { //Debug.Log(properties.name); if (properties.name == "data") { continue; } System.Type type = AdvancedScriptableObjectUtility.GetSerializedPropertyType(properties); //Debug.Log(type); if (type != null) { if (type.GetElementType().IsSubclassOf(typeof(AdvancedScriptableObject))) { SerializedProperty asoPropCopy = properties.Copy(); if (!_asoLists.ContainsKey(asoPropCopy.name)) { _asoLists.Add(asoPropCopy.name, new Editor_ASOList(asoPropCopy)); } continue; } else { SerializedProperty propCopy = properties.Copy(); if (!_asoLists.ContainsKey(propCopy.name)) { _lists.Add(propCopy.name, new Editor_List(propCopy)); } continue; } } } } #endregion _bListsCreated = true; //Debug.Log(string.Format("List count:{0} ASOList count:{1}",_lists.Count,_asoLists.Count)); }
void CreateNew(SerializedProperty property) { System.Type propType; propType = AdvancedScriptableObjectUtility.GetSerializedPropertyType(property); System.Type[] types = Assembly.GetAssembly(propType).GetTypes(); List <string> allTypes = (from System.Type t in types where t.IsSubclassOf(propType) select t.FullName).ToList(); if (!propType.IsAbstract) { allTypes.Add(propType.FullName); } var menu = new GenericMenu(); for (int i = 0; i < allTypes.Count; i++) { GUIContent gc = new GUIContent(allTypes[i]); menu.AddItem(gc, false, CreateObjectSelected, new ObjectSelection(property, allTypes[i])); } menu.ShowAsContext(); }
void List_AddDropdown(Rect buttonRect, ReorderableList list) { System.Type propType = AdvancedScriptableObjectUtility.GetSerializedPropertyType(_property).GetElementType(); System.Type[] types = Assembly.GetAssembly(propType).GetTypes(); List <string> allTypes = (from System.Type t in types where t.IsSubclassOf(propType) select t.FullName).ToList(); if (!propType.IsAbstract) { allTypes.Add(propType.FullName); } allTypes.Insert(0, "Empty"); var menu = new GenericMenu(); for (int i = 0; i < allTypes.Count; i++) { GUIContent gc = new GUIContent(allTypes[i]); menu.AddItem(gc, false, List_Dropdown_OnSelected, allTypes[i]); } menu.ShowAsContext(); }
void DrawBaseExcept() { SerializedProperty myProp = serializedObject.GetIterator(); while (myProp.NextVisible(true)) { if (!myProp.isArray && myProp.propertyType != SerializedPropertyType.ArraySize || myProp.isArray && myProp.propertyType == SerializedPropertyType.String) { if (myProp.name != "_parentAsset" && myProp.name != "data") { if (myProp.propertyType == SerializedPropertyType.ObjectReference) { System.Type type = AdvancedScriptableObjectUtility.GetSerializedPropertyType(myProp); if (type != null) { if (type.IsSubclassOf(typeof(AdvancedScriptableObject))) { EditorGUILayout.PropertyField(myProp); //var asoPropEditor = Editor.CreateEditor(myProp.objectReferenceValue); //asoPropEditor.OnInspectorGUI(); //ManualDrawASOProperty(myProp, type); } else { EditorGUILayout.PropertyField(myProp, new GUIContent(myProp.displayName), false); serializedObject.ApplyModifiedProperties(); } } } else { EditorGUILayout.PropertyField(myProp, new GUIContent(myProp.displayName), false); serializedObject.ApplyModifiedProperties(); } } } else if (myProp.isArray) { if (myProp.name != "_protoChildren") { System.Type type = AdvancedScriptableObjectUtility.GetSerializedPropertyType(myProp); if (type != null) { if (type.GetElementType().IsSubclassOf(typeof(AdvancedScriptableObject))) { if (_asoLists.ContainsKey(myProp.name)) { _asoLists[myProp.name].DrawList(); } } else { if (_lists.ContainsKey(myProp.name)) { _lists[myProp.name].DrawList(); } } } } } } }