// Use this for initialization void Start() { // プレハブ読み込み GameObject prefab = (GameObject)Resources.Load("Prefabs/Tile"); // 配置元のオブジェクト設定 GameObject stage = GameObject.FindWithTag("Stage"); //タイル配置 for (int i = 0; i < 7; i++) { for (int j = 0; j < 21; j++) { Debug.Log("x:" + prefab.transform.localScale.x); Vector3 tilePos = new Vector3( (float)(-30 + prefab.transform.localScale.x * i * 10), (float)(100 - prefab.transform.localScale.z * j * 10), -1 ); if (prefab != null) { GameObject instantObj = (GameObject)GameObject.Instantiate(prefab, tilePos, Quaternion.AngleAxis(90, Vector3.left)); tilepos[i, j] = tilePos; instantObj.transform.parent = stage.transform; tilecont ticon = instantObj.GetComponent <tilecont>(); ticon.i = i; ticon.j = j; } } } }
public void OnDrop(PointerEventData eventData) { /* var raycastResults = new List<RaycastResult>(); * EventSystem.current.RaycastAll ( eventData, raycastResults ); * * foreach ( var hit in raycastResults ) * { * // もし DroppableField の上なら、その位置に固定する * if ( hit.gameObject.CompareTag ( "DroppableField" ) ) * { * transform.position = hit.gameObject.transform.position; * this.enabled = false; * } * }*/ int layerMask = 1 << 8 | 1 << 9; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 100, layerMask)) { Debug.Log(hit.collider.tag); if (!exsitboss) { tilecont ticon = hit.collider.gameObject.GetComponent <tilecont>(); wkbo = ticon.hitaction(itemnumber); } if (itemnumber == 0) { exsitboss = wkbo; } } }