void DrawExpand(ILHotMonoProxyStruct monoStruct, IrpClassInfo classInfo, string baseName, SerializedProperty serializedProperty, bool draw) { foreach (var field in classInfo.Fields) { var fieldKey = string.Concat(baseName, field.FieldName); if (field.FieldType == typeof(string).ToString()) { DrawText(field.FieldName, fieldKey, monoStruct.StringValues, monoStruct.NewStringValues, draw); } else if (field.FieldType == typeof(float).ToString()) { DrawFloat(field.FieldName, fieldKey, monoStruct.FloatValues, monoStruct.NewFloatValues, draw); } else if (field.FieldType == typeof(bool).ToString()) { DrawBool(field.FieldName, fieldKey, monoStruct.BoolValues, monoStruct.NewBoolValues, draw); } else if (field.FieldType.Contains(typeof(UnityEngine.Object).ToString())) { DrawObject(field.FieldName, fieldKey, field.FieldType, monoStruct.ObjectValues, monoStruct.NewObjectValues, draw); } else { Debug.Log("field.FieldName " + field.FieldName); var info = ILReflectJsonImport.MonoClassInfoList.Find(i => i.ClassName == field.FieldType); if (info.IsObject == true) { DrawILObject(field.FieldName, fieldKey, field.FieldType, monoStruct, field.ClassInfo, draw); } else { var drawClass = field.ClassInfo; var currentValue = true; if (monoStruct.ExpandValues.ContainsKey(fieldKey)) { currentValue = monoStruct.ExpandValues[fieldKey]; } currentValue = EditorGUILayout.Foldout(currentValue, field.FieldName); if (currentValue) { EditorGUI.indentLevel += 1; DrawExpand(monoStruct, drawClass, string.Concat(fieldKey, "."), serializedProperty, true); EditorGUI.indentLevel -= 1; } else { DrawExpand(monoStruct, drawClass, string.Concat(fieldKey, "."), serializedProperty, false); } monoStruct.NewExpandValues.Add(fieldKey, currentValue); } } } }
void DrawILObject(string fieldName, string fieldKey, string fieldType, ILHotMonoProxyStruct monoStruct, IrpClassInfo fieldClassInfo, bool draw) { ILHotMonoProxy currentValue = null; if (monoStruct.ComponentValues.ContainsKey(fieldKey)) { currentValue = monoStruct.ComponentValues[fieldKey] as ILHotMonoProxy; } if (draw) { currentValue = EditorGUILayout.ObjectField(fieldKey, currentValue, typeof(ILHotMonoProxy), true) as ILHotMonoProxy; } monoStruct.NewComponentValues.Add(fieldKey, currentValue); if (monoStruct.NewComponentValues.ContainsKey(fieldKey)) { PickILHotMonoValues(fieldKey, monoStruct, (ILHotMonoProxy)monoStruct.NewComponentValues[fieldKey]); } }
void PickILHotMonoValues(string filedKey, ILHotMonoProxyStruct monoStruct, ILHotMonoProxy monoProxy) { for (var index = 0; index < monoProxy.BoolNames.Count; index++) { monoStruct.NewBoolValues.Add(string.Concat(filedKey, ".", monoProxy.BoolNames[index]), monoProxy.BoolValues[index]); } for (var index = 0; index < monoProxy.FloatNames.Count; index++) { monoStruct.NewFloatValues.Add(string.Concat(filedKey, ".", monoProxy.FloatNames[index]), monoProxy.FloatValues[index]); } for (var index = 0; index < monoProxy.StringNames.Count; index++) { monoStruct.NewStringValues.Add(string.Concat(filedKey, ".", monoProxy.StringNames[index]), monoProxy.StringValues[index]); } for (var index = 0; index < monoProxy.ObjectNames.Count; index++) { monoStruct.NewObjectValues.Add(string.Concat(filedKey, ".", monoProxy.ObjectNames[index]), monoProxy.ObjectValues[index]); } }