public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) { SerializedProperty target = prop.FindPropertyRelative("DataExpressionName"); SerializedObject serObj = target.serializedObject; var path = Application.dataPath + "/Plugins/DataModel/"; Assembly ass = Assembly.LoadFile(Path.Combine(path, "GameDataDefine.dll")); Type[] types = ass.GetTypes(); mType = null; UIClassBinding tarObj = serObj.targetObject as UIClassBinding; InverseBinding tarObj1 = serObj.targetObject as InverseBinding; { var __array3 = types; var __arrayLength3 = __array3.Length; for (int __i3 = 0; __i3 < __arrayLength3; ++__i3) { var t = __array3[__i3]; { if (tarObj != null && t.Name == tarObj.BindingName.ClassName) { mType = t; break; } if (tarObj1 != null && t.Name == tarObj1.BindingName.ClassName) { mType = t; break; } } } } List <List <string> > list = new List <List <string> >(); List <string> thislist = new List <string>(); thislist.Add("this"); list.Add(thislist); var depth = 0; FillProperties(mType, ref list, null, false, depth); int index = 0; string strValue = target.stringValue; string current = strValue; // var strList = strValue.Split('.'); // string subStr = ""; // if (strList.Count() <= 3) // { // current = target.stringValue; // } // else // { // for (int i = 0; i < 3; i++) // { // current += strList[i]; // if (i != 3 -1) // { // current += '.'; // } // } // // // for (int i = 3; i < strList.Count(); i++) // { // subStr += strList[i]; // if (i != strList.Count() - 1) // { // subStr += '.'; // } // } // } string[] names = GetNames(list, current, out index); GUI.changed = false; EditorGUI.BeginDisabledGroup(target.hasMultipleDifferentValues); // if (strList.Count() >= 3) // { // rect.width = rect.width / 2; // } int choice = EditorGUI.Popup(rect, "", index, names); // if (strList.Count() >= 3) // { // rect.x = rect.width ; // } if (GUI.changed && choice > 0) { List <string> ent = list[choice - 1]; string del = ""; for (var j = 0; j < ent.Count; j++) { del += ent[j]; if (j != ent.Count - 1) { del += "."; } } target.stringValue = del; // subStr = ""; current = del; GUI.changed = false; } EditorGUI.EndDisabledGroup(); //ShowSubsequent(rect,target,current,subStr); }
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label) { SerializedProperty target = prop.FindPropertyRelative("ClassName"); string curSel = target.stringValue; List <string> strList = new List <string>(); //List<string> strListOrder = new List<string>(); SerializedObject serObj = target.serializedObject; //strListOrder.Add(curSel == "" ? "none" : curSel); int index = 0; if (serObj.targetObject is BindDataRoot) { var path = Application.dataPath + "/Plugins/DataModel/"; Assembly ass = Assembly.LoadFile(Path.Combine(path, "GameDataDefine.dll")); Type[] types = ass.GetTypes(); int tempIndex = 0; { var __array1 = types; var __arrayLength1 = __array1.Length; for (int __i1 = 0; __i1 < __arrayLength1; ++__i1) { var t = (Type)__array1[__i1]; { if (CheckClassProperChanged(t, 0)) { strList.Add(t.Name); } } } } } else { Transform tf = null; BindDataRoot root = null; if (serObj.targetObject is InverseBinding) { InverseBinding tarObj = serObj.targetObject as InverseBinding; //tf = tarObj.gameObject.transform.parent; tf = tarObj.gameObject.transform; } else if (serObj.targetObject is UIClassBinding) { UIClassBinding tarObj = serObj.targetObject as UIClassBinding; //tf = tarObj.gameObject.transform.parent; tf = tarObj.gameObject.transform; } while (tf != null) { root = tf.gameObject.GetComponent <BindDataRoot>(); if (root != null) { { var __list2 = root.BindingNamelList; var __listCount2 = __list2.Count; for (int __i2 = 0; __i2 < __listCount2; ++__i2) { var name = __list2[__i2]; { strList.Add(name.ClassName); } } } } tf = tf.parent; } } if (strList.Count == 0) { return; } strList.Sort(); { var __list3 = strList; var __listCount3 = __list3.Count; for (int __i3 = 0; __i3 < __listCount3; ++__i3) { var s = __list3[__i3]; { if (curSel == s) { break; } index++; } } } GUI.changed = false; EditorGUI.BeginDisabledGroup(target.hasMultipleDifferentValues); int choice = EditorGUI.Popup(rect, "", index, strList.ToArray()); if (GUI.changed && choice >= 0) { string str = strList[choice]; target.stringValue = str; } EditorGUI.EndDisabledGroup(); }