Exemple #1
0
        public string ExecuteOnTarget(HeroKitObject targetObject, string scriptName, MethodInfo method)
        {
            //------------------------------------
            // get the component that contains the script
            //------------------------------------

            MonoBehaviour component = HeroKitCommonRuntime.GetComponentFromScript(heroKitObject, targetObject, scriptName);

            //------------------------------------
            // get the parameters for the script
            //------------------------------------
            System.Object[] parameters = new System.Object[0];
            if (component != null)
            {
                parameters = ParameterValue.GetValueA(heroKitObject, 4, method);
            }
            else
            {
                Debug.LogError(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, "Component does not exist on the game object."));
            }

            //------------------------------------
            // invoke the method in the script
            //------------------------------------
            System.Object returnValue = method.Invoke(component, parameters);

            //------------------------------------
            // save the return value in the hero object
            //------------------------------------
            ParameterValue.SetValueB(heroKitObject, 20, 21, returnValue);

            // debug string
            string debugInfo = "";

            if (heroKitObject.debugHeroObject)
            {
                string argumentNames = "";
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (parameters[i] != null)
                    {
                        argumentNames += ", arg[" + i + "]=" + parameters[i].ToString();
                    }
                }
                string returnName = "";
                if (returnValue != null)
                {
                    returnName += ", return=" + returnValue.ToString();
                }

                debugInfo = argumentNames + returnName;
            }
            return(debugInfo);
        }
Exemple #2
0
        public void ExecuteOnTarget(HeroKitObject targetObject, string scriptName)
        {
            MonoBehaviour component = HeroKitCommonRuntime.GetComponentFromScript(heroKitObject, targetObject, scriptName);

            FieldInfoValue.SetValueA(targetObject, 3, 4, component);
        }