예제 #1
0
        void ListAddItem(object value = null)
        {
            var drawer = new MethodPropertyDrawer(requiredType.GetElementType(), "", value, privateFields, obsolete);

            drawer.OnRequireRedraw += RequireRedraw;
            arrayContentDrawer.Add(drawer);
        }
예제 #2
0
 void InitMethodParams()
 {
     selectedCtor = methods[selectedMethodIndex].ctorInfo;
     if (selectedCtor != null)
     {
         selectedMethod = null;
         component      = null;
         parameterInfo  = selectedCtor.GetParameters();
     }
     else
     {
         selectedMethod = methods[selectedMethodIndex].method;
         component      = methods[selectedMethodIndex].target;
         parameterInfo  = selectedMethod.GetParameters();
     }
     parameters = new MethodPropertyDrawer[parameterInfo.Length];
     for (int i = 0; i < parameterInfo.Length; i++)
     {
         var info = parameterInfo[i];
         parameters[i] = new MethodPropertyDrawer(info.ParameterType, info.Name, info.IsOptional ? info.DefaultValue : null, privateFields, obsolete);
         parameters[i].OnRequireRedraw += RequireRedraw;
     }
     result          = null;
     thrownException = null;
 }
예제 #3
0
 public void Call()
 {
     if (selectedMethod == null || ctorMode ? ctorType == null : component == null || parameters == null)
     {
         return;
     }
     try {
         thrownException = null;
         var requestData = parameters.Select(d => d.Value).ToArray();
         if (selectedCtor != null)
         {
             var returnData = selectedCtor.Invoke(requestData);
             result = new MethodPropertyDrawer(selectedCtor.ReflectedType, "Constructed object", returnData, privateFields, obsolete);
         }
         else
         {
             var returnData = selectedMethod.Invoke(component, requestData);
             result = selectedMethod.ReturnType == typeof(void) ?
                      null :
                      new MethodPropertyDrawer(selectedMethod.ReturnType, "Return data", returnData, privateFields, obsolete);
         }
         for (int i = 0; i < Math.Min(parameters.Length, requestData.Length); i++)
         {
             parameters[i].Value = requestData[i];
             if (parameters[i].ReferenceMode)
             {
                 Helper.AssignValue(parameters[i].RefFieldInfo, parameters[i].Component, requestData[i]);
             }
         }
     } catch (Exception ex) {
         thrownException = ex.InnerException ?? ex;
         Debug.LogException(thrownException);
         throw;
     }
 }
예제 #4
0
 void InitComponentMethods(bool resetIndex = true)
 {
     methods.Clear();
     if (ctorMode)
     {
         AddComponentMethod(ctorType);
     }
     else
     {
         AddComponentMethod(component);
     }
     if (ctorMode)
     {
         methodNames = methods.Select((m, i) => GetMethodNameFormatted(m, i)).ToArray();
     }
     else if (drawHeader)
     {
         var gameObject = component as GameObject;
         if (gameObject != null)
         {
             foreach (var c in gameObject.GetComponents(typeof(Component)))
             {
                 AddComponentMethod(c);
             }
         }
         methodNames = methods.Select((m, i) => string.Format(
                                          "{0} ({1})/{2}",
                                          m.target.GetType().Name,
                                          Helper.ObjIdOrHashCode(m.target),
                                          GetMethodNameFormatted(m, i)
                                          )).ToArray();
     }
     else
     {
         methodNames = methods.Select((m, i) => GetMethodNameFormatted(m, i)).ToArray();
     }
     if (!resetIndex && selectedMethod != null)
     {
         selectedMethodIndex = methods.FindIndex(m => m.method == selectedMethod);
         if (selectedMethodIndex >= 0)
         {
             return;
         }
     }
     selectedMethodIndex = -1;
     selectedMethod      = null;
     selectedCtor        = null;
     parameterInfo       = null;
     parameters          = null;
     result          = null;
     thrownException = null;
 }