protected override void OnSingleInitialization() { ignored = DelegateSettings.IgnoredMethods; // initialize adding area and foldout keys adding = new AddingData(); kAdvanced = id + "advanced"; kAdd = id + "add"; kInvoke = id + "invoke"; headerString = string.Format("{0} ({1})", niceName, memberTypeName); // make sure delegate is not null if (memberValue == null) { memberValue = memberType.Instance <BaseDelegate>(); } // initialize arguments data (used when invoking the delegate from the editor) int len = memberValue.ParamTypes.Length; argValues = new object[len]; argMembers = new EditorMember[len]; for (int iLoop = 0; iLoop < len; iLoop++) { int i = iLoop; var paramType = memberValue.ParamTypes[i]; argValues[i] = paramType.GetDefaultValueEmptyIfString(); var argMember = new ArgMember( @getter: () => argValues[i], @setter: x => argValues[i] = x, @target: argValues, @unityTarget: unityTarget, @name: string.Format("({0})", paramType.GetNiceName()), @id: id + i, @dataType: paramType, @attributes: null ); argMember.Target = rawTarget; argMembers[i] = argMember; } #if DBG Log("Delegate drawer init. " + niceName); #endif }
public void Initialize(MethodInfo method, object rawTarget, UnityObject unityTarget, string id, BaseGUI gui) { this.gui = gui; if (initialized) { return; } initialized = true; this.id = id; this.rawTarget = rawTarget; niceName = method.GetNiceName(); invoke = method.DelegateForCallMethod(); var argInfos = method.GetParameters(); int len = argInfos.Length; argValues = new object[len]; argKeys = new string[len]; argMembers = new ArgMember[len]; for (int iLoop = 0; iLoop < len; iLoop++) { int i = iLoop; var arg = argInfos[i]; var argType = arg.ParameterType; argKeys[i] = id + argType.FullName + arg.Name; argValues[i] = prefs.TryGet(argInfos[i].ParameterType, argKeys[i]); argMembers[i] = new ArgMember( @getter: () => argValues[i], @setter: x => argValues[i] = x, @target: argValues, @unityTarget: unityTarget, @attributes: new Attribute[0], @name: arg.Name, @id: argKeys[i], @dataType: argType ); } #if DBG Log("Method drawer init"); #endif }