Ejemplo n.º 1
0
    protected override void Initialize()
    {
        switch (m_codeType)
        {
        case ECodeType.FileName:
            break;

        case ECodeType.TextAsset:
            AppDomain.BuildFile(m_className, m_ta.text);
            break;

        case ECodeType.Text:
            AppDomain.BuildFile(m_className, m_codeText);
            break;
        }

        type = CQuark.AppDomain.GetTypeByKeywordQuiet(m_className);
        if (type == null)
        {
            Debug.LogError("Type:" + m_className + "不存在与脚本项目中");
            return;
        }
        cclass  = type._class as Class_CQuark;
        content = new CQ_Content();

        //TODO 最好在编译的时候就做,不要在实例化的时候做
        RegisterMember("gameObject", typeof(GameObject));
        RegisterMember("transform", typeof(Transform));

        inst = type._class.New(content, null).value as CQuark.CQClassInstance;

        SetMember("gameObject", typeof(GameObject), this.gameObject);
        SetMember("transform", typeof(Transform), this.transform);


        if (cclass.functions.ContainsKey("Update"))
        {
            m_update = cclass.functions["Update"].expr_runtime;
        }
        if (cclass.functions.ContainsKey("FixedUpdate"))
        {
            m_fixedpdate = cclass.functions["FixedUpdate"].expr_runtime;
        }
        _updateContent          = new CQ_Content();
        _updateContent.CallType = cclass;
        _updateContent.CallThis = inst;
    }