// 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); }
public void InitAndDestroy() { if (!inited) { inited = true; JSComponent script = gameObject.AddComponent <JSComponent>(); script.jsClassName = ScriptName; script.jsFail = false; script.init(true); SerializeData(script); script.callAwake(); script.callOnAwake(); script.callOnEnable(); Destroy(this); } }