// Use this for initialization void Start() { if (BlockCollectionController.Instance == null) { Destroy(this); return; } //サーバがオブジェクト生成時にlocalPositionを初期位置に設定しているので //localPositionを維持したまま、Parentを設定する。 transform.localScale = scale; transform.SetParent(BlockCollectionController.Instance.transform, false); GetComponent <Renderer>().material.SetColor("_Color", color); historyManager = BlockCollectionController.Instance.blockHistoryManager; isActive = gameObject.activeSelf; }
// Use this for initialization // Awake に書くことで、 Instantiate が呼ばれたらほかの処理が走る前に実行される void Awake() { string jsonFilePath = Path.Combine(Application.streamingAssetsPath, "Jsons"); jsonFilePath = Path.Combine(jsonFilePath, JsonFileName); if (!File.Exists(jsonFilePath)) { print(string.Format("Cannot Find Json File at {0}", jsonFilePath)); return; } string json = File.ReadAllText(jsonFilePath); data = JsonConvert.DeserializeObject <BlockCollectionData>(json); // blockCollectionMap へのコピー blockCollectionMap = new int[data.blockArrangement.Length][][]; for (int i = 0; i < blockCollectionMap.Length; i++) { blockCollectionMap[i] = new int[data.blockArrangement[0].Length][]; for (int j = 0; j < blockCollectionMap[0].Length; j++) { blockCollectionMap[i][j] = new int[data.blockArrangement[0][0].Length]; for (int k = 0; k < blockCollectionMap[0][0].Length; k++) { // ここで 0 のところは 1 に置き換える(バウンディングボックスを作るため) blockCollectionMap[i][j][k] = data.blockArrangement[i][j][k] == 0 ? 1 : data.blockArrangement[i][j][k]; } } } // ここでつくることですべての場所で共通のManagerとなる blockHistoryManager = new BlockHistoryManager(); // set this speech manager as global listener InputManager.Instance.AddGlobalListener(gameObject); }