示例#1
0
    public static int AddComponent(int id, int type)
    {
        var go = LuaReference.Get(id);

        if (go)
        {
            go.AddComponent(LuaReference.GetComponentType(type));
            return(id);
        }
        return(LuaReference.INVALID_GAMEOBJECT_ID);
    }
示例#2
0
    public static void SetEnable(int id, int type, int enable)
    {
        var go = LuaReference.Get(id);

        if (go)
        {
            var behaviour = go.GetComponent(LuaReference.GetComponentType(type)) as Behaviour;
            if (behaviour)
            {
                behaviour.enabled = enable == 1;
            }
        }
    }
示例#3
0
    public static void DestroyComponent(int id, int type)
    {
        var go = LuaReference.Get(id);

        if (go)
        {
            var componet = go.GetComponent(LuaReference.GetComponentType(type));

            if (componet)
            {
                UnityEngine.Object.DestroyImmediate(componet);
            }
        }
    }
示例#4
0
    public static int IsEnable(int id, int type)
    {
        var go = LuaReference.Get(id);

        if (go)
        {
            var behaviour = go.GetComponent(LuaReference.GetComponentType(type)) as Behaviour;
            if (behaviour)
            {
                return(behaviour.enabled ? 1:0);
            }
        }
        return(0);
    }
示例#5
0
    public static int FindChildWithComponent(int id, int type)
    {
        var go = LuaReference.Get(id);

        if (go)
        {
            var component = go.GetComponentInChildren(LuaReference.GetComponentType(type));
            if (component)
            {
                return(LuaReference.Add(component.gameObject));
            }
        }
        return(LuaReference.INVALID_GAMEOBJECT_ID);
    }