コード例 #1
0
    void changeLayer() //GameScene 넘어가기 전 무기 Layer 변경: Touchable -> weapon
    {
        layerChange = GM.gameObject.GetComponent <LayerChange>();
        s_itemSpawn = GameObject.Find("itemSpawn").GetComponent <ItemSpawn>();
        int itemSpawnLens = s_itemSpawn.itemSpawn.Length;

        GameObject[] Items = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
        int          len   = Items.Length;

        touchableItems = new GameObject[itemSpawnLens];
        int idx = 0;

        for (int i = 0; i < len; i++)
        {
            if (Items[i].layer == (int)eLAYER.TOUCHABLE)
            {
                touchableItems[idx] = Items[i];
                if (touchableItems[idx].tag == "weapon")
                {
                    layerChange.InputWeaponArr(touchableItems[idx]);
                }
                idx++;
            }
        }
    }
コード例 #2
0
    void Update()
    {
        if (!IsLayerChange) //무기아이템 GameScene으로 넘어갈 때 weapon layer로 변경
        {
            IsLayerChange = true;
            layerChange   = GM.gameObject.GetComponent <LayerChange>();
            ItemSpawn1 s_itemSpawn   = GameObject.Find("itemSpawn").GetComponent <ItemSpawn1>();
            int        itemSpawnLens = s_itemSpawn.itemSpawn.Length;

            GameObject[] Items = GameObject.FindObjectsOfType(typeof(GameObject)) as GameObject[];
            int          len   = Items.Length;
            touchableItems = new GameObject[itemSpawnLens];
            int idx = 0;
            for (int i = 0; i < len; i++)
            {
                if (Items[i].layer == (int)eLAYER.TOUCHABLE)
                {
                    touchableItems[idx] = Items[i];
                    if (touchableItems[idx].tag == "weapon")
                    {
                        layerChange.InputWeaponArr(touchableItems[idx]);
                    }
                    idx++;
                }
            }
        }
        if (Input.GetMouseButtonDown(0) && highlightBox.activeSelf == true)
        {
            TouchItem();
        }
    }