예제 #1
0
    /*
     * GameObject.AddComponent<T>()
     */
    public static bool GameObject_AddComponentT1(JSVCall vc, int count)
    {
        help_getGoAndType(vc);

        if (typeInfo.IsCSMonoBehaviour)
        {
            Component com = go.AddComponent(type);
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, com);
        }
        else
        {
            string jsComponentName = JSCache.GetMonoBehaviourJSComponentName(typeString);
            Type   jsComponentType = typeof(JSComponent);
            if (string.IsNullOrEmpty(jsComponentName))
            {
                Debug.LogWarning(string.Format("\"{0}\" has no JSComponent_XX. Use JSComponent instead.", typeString));
            }
            else
            {
                jsComponentType = JSDataExchangeMgr.GetTypeByName(jsComponentName, jsComponentType);
            }

            JSComponent jsComp = (JSComponent)go.AddComponent(jsComponentType);
            jsComp.jsClassName = typeString;
            jsComp.jsFail      = false;
            jsComp.init(true);
            jsComp.callAwake(); // Òªµ÷Óà js µÄ Awake

            //JSApi.JSh_SetRvalObject(vc.cx, vc.vp, jsComp.jsObj);
            JSApi.setObject((int)JSApi.SetType.Rval, jsComp.GetJSObjID(false));
        }
        return(true);
    }
예제 #2
0
    // GameObject.AddComponent<T>()
    public static bool GameObject_AddComponentT1(JSVCall vc, int count)
    {
        help_getGoAndType(vc);

        if (typeInfo.IsCSMonoBehaviour)
        {
            Component com = go.AddComponent(type);
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, com);
        }
        else
        {
            // TODO
            JSComponent jsComp = go.AddComponent <JSComponent>();
            jsComp.jsClassName = typeString;
            jsComp.jsFail      = false;
            jsComp.init(true);
            if (go.activeInHierarchy)
            {
                jsComp.callAwake(); // Òªµ÷Óà js µÄ Awake
                jsComp.callOnAwake();
                jsComp.callOnEnable();
            }

            //JSApi.JSh_SetRvalObject(vc.cx, vc.vp, jsComp.jsObj);
            JSApi.setObject((int)JSApi.SetType.Rval, jsComp.GetJSObjID(false));
        }
        return(true);
    }
예제 #3
0
    void SerializeData(JSComponent script)
    {
        int jsId = script.GetJSObjID(false);

        if (jsId == 0)
        {
            return;
        }

        if (Gos != null)
        {
            foreach (var n in Gos)
            {
                JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, n.v);
                SetField(jsId, n.name);
            }
        }
        if (Ints != null)
        {
            foreach (var n in Ints)
            {
                JSApi.setInt32((int)JSApi.SetType.SaveAndTempTrace, n.v);
                SetField(jsId, n.name);
            }
        }
        if (Strings != null)
        {
            foreach (var n in Strings)
            {
                JSApi.setStringS((int)JSApi.SetType.SaveAndTempTrace, n.v);
                SetField(jsId, n.name);
            }
        }
        if (Bools != null)
        {
            foreach (var n in Bools)
            {
                JSApi.setBooleanS((int)JSApi.SetType.SaveAndTempTrace, n.v);
                SetField(jsId, n.name);
            }
        }
    }