Ejemplo n.º 1
0
    // 调用脚本实例成员函数
    public object Call(SInstance scriptInstance, string funName, params object[] _params)
    {
        if (scriptInstance == null)
        {
            return(null);
        }

#if UNITY_EDITOR
        try
        {
            if (!scriptInstance.type.functions.ContainsKey(funName))
            {
                Debug.LogWarning(string.Format("Call({0}.{1}): fun not found!", scriptInstance.type.Name, funName));
                return(null);
            }
#endif
        BetterList <CLS_Content.Value> paramList = ScriptParamConvert(_params);
        CLS_Content.Value retVal = scriptInstance.type.MemberCall(m_clsContent, scriptInstance, funName, paramList);
        CLS_Content.PoolParamList(paramList);
        return(retVal != null ? retVal.value : null);

#if UNITY_EDITOR
    }
    catch (System.Exception ex)
    {
        Debug.LogError(DumpStack(ex));
        return(null);
    }
#endif
    }
Ejemplo n.º 2
0
    // 调用脚本静态函数
    public object CallStatic(string className, string funName, params object[] _params)
    {
#if UNITY_EDITOR
        try
        {
            if (string.IsNullOrEmpty(className) || string.IsNullOrEmpty(funName))
            {
                return(null);
            }
#endif
        CLS_Type_Class type = m_clsEnv.GetTypeByKeywordQuiet(className) as CLS_Type_Class;
        if (type == null)
        {
            Debug.LogWarning(string.Format("CallStatic({0}.{1}): class not found!", className, funName));
            return(null);
        }

        if (!type.compiled)
        {
            RuntimeCompilerClass(className);
        }

        BetterList <CLS_Content.Value> paramList = ScriptParamConvert(_params);
        CLS_Content.Value retVal = type.function.StaticCall(m_clsContent, funName, paramList);
        CLS_Content.PoolParamList(paramList);
        return(retVal != null ? retVal.value : null);

#if UNITY_EDITOR
    }

    catch (System.Exception ex)
    {
        Debug.LogError(DumpStack(ex));
        return(null);
    }
#endif
    }