protected void recursevelyAdd(object obj, FieldOrProperty fieldOrProperty, string parent) { object derivedObj = tracker.ObjectDerivedFromFields[obj][fieldOrProperty.Name()]; if (derivedObj == null || (tracker.ObjectsOwners.ContainsKey(derivedObj) && !tracker.ObjectsOwners[derivedObj].Key.Equals(obj)) || !tracker.ObjectsOwners[derivedObj].Value.Equals(fieldOrProperty.Name()) || derivedObj.Equals(tracker.GO)) { // Debug.Log(fieldOrProperty.Name()+" returning "); return; } if (tracker.ObjectsProperties.ContainsKey(derivedObj)) { Dictionary <string, FieldOrProperty> derivedObjProperties = tracker.ObjectsProperties[derivedObj]; foreach (string s in derivedObjProperties.Keys) { if (tracker.ObjectsToggled[derivedObjProperties[s]]) { //Debug.Log(s + " is toggled"); if (tracker.IsMappable(derivedObjProperties[s])) { //Debug.Log(derivedObjProperties[s].Name() + " toggled"); // Debug.Log("adding " + parent + fieldOrProperty.Name() + "^" + s); string adding = parent + fieldOrProperty.Name() + "^" + s; properties.Add(adding); if (tracker.IsBaseType(derivedObjProperties[s])) { specificConfiguration(derivedObjProperties[s], adding); } int startFrom = 0; while (startFrom < adding.Length && adding.IndexOf("^", startFrom) != adding.LastIndexOf("^")) { int currentIndex = adding.IndexOf("^", startFrom); properties.Add(adding.Substring(0, currentIndex)); startFrom = currentIndex + 1; } if (!tracker.IsBaseType(derivedObjProperties[s])) { tracker.basicTypeCollectionsConfigurations[derivedObjProperties[s]].propertyName = adding; advancedConf.Add(tracker.basicTypeCollectionsConfigurations[derivedObjProperties[s]]); } } else if (tracker.ObjectDerivedFromFields.ContainsKey(derivedObj) && !tracker.IsBaseType(derivedObjProperties[s])) { //Debug.Log("recursin on " + parent + fieldOrProperty.Name() + "^" + derivedObjProperties[s].Name()); recursevelyAdd(derivedObj, derivedObjProperties[s], parent + fieldOrProperty.Name() + "^"); } } } } }
protected void drawObjectProperties() { SimpleGameObjectsTracker st = tracker.basicTypeCollectionsConfigurations[objectToConfigure]; GUILayout.Label("Configure " + st.objType + " object for " + objectToConfigure.Name() + " property ", EditorStyles.boldLabel); List <string> propertiesNames = new List <string>(); //MyDebugger.MyDebug(st.propertiesToggled); foreach (string s in st.propertiesToggled.Keys) { propertiesNames.Add(s); } using (var h = new EditorGUILayout.VerticalScope()) { using (var scrollView = new EditorGUILayout.ScrollViewScope(helpScroll)) { foreach (string s in propertiesNames) { st.propertiesToggled[s] = EditorGUILayout.ToggleLeft(s, st.propertiesToggled[s]); } helpScroll = scrollView.scrollPosition; } } EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); bool cancel = GUILayout.Button("Cancel"); bool save = GUILayout.Button("Save"); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); if (cancel) { if (st.toSave.Count == 0) { tracker.basicTypeCollectionsConfigurations.Remove(objectToConfigure); tracker.ObjectsToggled[objectToConfigure] = false; } objectMode = false; } if (save) { st.save(); if (st.toSave.Count == 0) { tracker.basicTypeCollectionsConfigurations.Remove(objectToConfigure); tracker.ObjectsToggled[objectToConfigure] = false; } objectMode = false; } }
protected void addSubProperties(object obj, string name, object objOwner) { if (tracker.ObjectsOwners.ContainsKey(obj) && !obj.GetType().IsValueType&& (!tracker.ObjectsOwners[obj].Key.Equals(objOwner) || !tracker.ObjectsOwners[obj].Value.Equals(name)) || obj.Equals(tracker.GO)) { EditorGUI.BeginDisabledGroup(true); if (obj.Equals(tracker.GO)) { EditorGUILayout.ToggleLeft("This is " + chosenGO + " object", true); } else if (!tracker.ObjectsOwners[obj].Value.Equals(name)) { EditorGUILayout.ToggleLeft("object already listed as " + tracker.ObjectsOwners[obj].Value, true); } else { EditorGUILayout.ToggleLeft("object already listed in an upper level", true); } EditorGUI.EndDisabledGroup(); return; } if (!tracker.ObjectsToggled.ContainsKey(obj)) { tracker.ObjectsToggled.Add(obj, false); } if (!tracker.ObjectsProperties.ContainsKey(obj)) { tracker.updateDataStructures(obj, null, null); } foreach (FieldOrProperty f in tracker.ObjectsProperties[obj].Values) { bool disabled = tracker.ObjectDerivedFromFields[obj][f.Name()] == null; EditorGUI.BeginDisabledGroup(disabled); if (isMappable(f)) { EditorGUILayout.BeginHorizontal(); tracker.ObjectsToggled[f] = EditorGUILayout.ToggleLeft(f.Name(), tracker.ObjectsToggled[f]); addCustomFields(f); if (tracker.ObjectsToggled[f] && !tracker.IsBaseType(f)) { bool configure = GUILayout.Button("Configure Object"); if (configure) { objectMode = true; objectToConfigure = f; helpScroll = new Vector2(0, 0); //MyDebugger.MyDebug("num: "+tracker.basicTypeCollectionsConfigurations.Count); if (!tracker.basicTypeCollectionsConfigurations.ContainsKey(f)) { //MyDebugger.MyDebug("f " + tracker.basicTypeCollectionsConfigurations[f]); MyDebugger.MyDebug("adding simple tracker for " + objectToConfigure.Name() + " that is a " + objectToConfigure.Type()); tracker.basicTypeCollectionsConfigurations.Add(f, new SimpleGameObjectsTracker(objectToConfigure.Type())); } tracker.basicTypeCollectionsConfigurations[f].getBasicProperties(); drawObjectProperties(); } } EditorGUILayout.EndHorizontal(); } else { tracker.ObjectsToggled[f] = EditorGUILayout.Foldout(tracker.ObjectsToggled[f], f.Name()) && !disabled; if (tracker.ObjectsToggled[f]) { EditorGUI.indentLevel++; addSubProperties(tracker.ObjectDerivedFromFields[obj][f.Name()], f.Name(), obj); EditorGUI.indentLevel--; } } EditorGUI.EndDisabledGroup(); } }
protected void addProperties() { using (var h = new EditorGUILayout.VerticalScope()) { using (var scrollView = new EditorGUILayout.ScrollViewScope(mainScroll)) { GameObject gO = tracker.GO; foreach (FieldOrProperty obj in tracker.ObjectsProperties[gO].Values) { bool disabled = tracker.ObjectDerivedFromFields[gO][obj.Name()] == null; EditorGUI.BeginDisabledGroup(disabled); if (isMappable(obj)) { EditorGUILayout.BeginHorizontal(); tracker.ObjectsToggled[obj] = EditorGUILayout.ToggleLeft(obj.Name(), tracker.ObjectsToggled[obj]); addCustomFields(obj); if (tracker.ObjectsToggled[obj] && !tracker.IsBaseType(obj)) { bool configure = GUILayout.Button("Configure Object"); if (configure) { objectMode = true; objectToConfigure = obj; helpScroll = new Vector2(0, 0); if (!tracker.basicTypeCollectionsConfigurations.ContainsKey(obj)) { MyDebugger.MyDebug("adding simple tracker for " + objectToConfigure.Name() + " that is a " + objectToConfigure.Type()); tracker.basicTypeCollectionsConfigurations.Add(obj, new SimpleGameObjectsTracker(objectToConfigure.Type())); } tracker.basicTypeCollectionsConfigurations[obj].getBasicProperties(); drawObjectProperties(); } } EditorGUILayout.EndHorizontal(); } else { tracker.ObjectsToggled[obj] = EditorGUILayout.Foldout(tracker.ObjectsToggled[obj], obj.Name()) && !disabled; if (tracker.ObjectsToggled[obj]) { EditorGUI.indentLevel++; addSubProperties(tracker.ObjectDerivedFromFields[gO][obj.Name()], obj.Name(), gO); EditorGUI.indentLevel--; } } EditorGUI.EndDisabledGroup(); } foreach (Component c in tracker.GOComponents[gO]) { //MyDebugger.MyDebug(c); tracker.ObjectsToggled[c] = EditorGUILayout.Foldout(tracker.ObjectsToggled[c], c.GetType().ToString()); if (tracker.ObjectsToggled[c]) { EditorGUI.indentLevel++; addSubProperties(c, c.GetType().ToString(), gO); EditorGUI.indentLevel--; } } mainScroll = scrollView.scrollPosition; } } }