Пример #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);
    }