Ejemplo n.º 1
0
    private void ExecutePostActionAttached(string name)
    {                                                                                   //TODO sécuriser un peu tout ça, envoyer des exceptions si la méthode n'existe pas, si _caller est null
        DialogPostAction[] scripts         = _caller.GetComponents <DialogPostAction>();
        DialogPostAction   scriptToExecute = scripts[_dialogXML.dialog[_index].id - 1]; //Les id commencent à partir de 1 (car 0 est la valeur par défaut) mais les scripts commencent à 0 !

        Type       t        = scriptToExecute.GetType();
        MethodInfo function = t.GetMethod(name);

        function.Invoke(scriptToExecute, null);
    }
Ejemplo n.º 2
0
    private void ExecutePostActionNotAttached(string scriptName, string functionName)
    {//TODO sécuriser un peu tout ça, envoyer des exceptions si la méthode n'existe pas
        DialogPostAction scriptToExecute = _caller.GetComponent <DialogPostAction>();

        if (scriptToExecute != null)
        {
            Type       t        = scriptToExecute.GetType();
            MethodInfo function = t.GetMethod(functionName);
            function.Invoke(scriptToExecute, null);
        }
        else
        {
            Type       t        = Type.GetType(scriptName);
            MethodInfo function = t.GetMethod(functionName);
            object     o        = Activator.CreateInstance(t);
            function.Invoke(o, null);
        }
    }