Example #1
0
        // 自动赋值
        public bool AutoSetValue(object value, FieldInfo fieldInfo, GameObject root)
        {
            object cv = fieldInfo.GetValue(value);

            if (cv != null)
            {
                var src = CSharpAgentSerialize.GetUnityObject(type, cv);
                if (src != null)
                {
                    return(false);
                }
            }

            var obj = ObjectType.GetFind(root.transform, fieldInfo.Name, unityType, (itor) => { return(IsBindType(itor as Component, realType)); });

            if (obj == null)
            {
                obj = GetILMonoBindType(root, unityType, realType);
            }
            if (obj != null)
            {
                csharpAgentSerialize.SetObject(ref cv, obj);
                fieldInfo.SetValue(value, cv);
                return(true);
            }

            return(false);
        }
Example #2
0
        public object OnGUI(string label, object value, System.Type type, out bool isDirty)
        {
#if USE_HOT
            if (type is ILRuntimeWrapperType)
            {
                type = ((ILRuntimeWrapperType)type).RealType;
            }
#endif
            isDirty = false;
            var src = CSharpAgentSerialize.GetUnityObject(this.type, value);
            var nv  = EditorGUILayout.ObjectField(label, src, unityType, true);
            if (nv != src)
            {
                isDirty = true;
                csharpAgentSerialize.SetObject(ref value, nv);
            }
            else
            {
                isDirty = false;
            }

            return(value);
        }
Example #3
0
        public object OnGUI(string label, object value, System.Type type, out bool isDirty)
        {
            type    = wxb.IL.Help.GetRealType(type);
            isDirty = false;
            var    src = CSharpAgentSerialize.GetUnityObject(this.type, value);
            Object nv  = null;

            ObjectType.CopyFieldName(label, () =>
            {
                nv = EditorGUILayout.ObjectField($"{label}({realType.Name})", src, unityType, true);
            });
            if (nv != src)
            {
                isDirty = true;
                csharpAgentSerialize.SetObject(ref value, nv);
            }
            else
            {
                isDirty = false;
            }

            return(value);
        }