Example #1
0
        /// <summary>
        /// アンカーの初期化と再設置
        /// </summary>
        public void Init()
        {
            isLoadedAnchor = false;
            // アンカーデータ読み込み
            var data = JsonAnchorData.LoadAnchorData();

            if (data != null)
            {
                // 初期化
                var loadedCount = 0;
                for (var i = 0; i < data.Count; i++)
                {
                    var hub = new HubAnchor(i.ToString());
                    // アンカー再設置
                    hub.LoadedHubAnchor += () =>
                    {
                        loadedCount++;
                        if (loadedCount == data.Count)
                        {
                            isLoadedAnchor = true;
                        }
                    };
                    hub.LoadAnchorData(anchor, data[i]);
                    hubAnchors.Add(hub);
                }
            }
        }
Example #2
0
        /// <summary>
        /// HubAnchorの再設置
        /// </summary>
        /// <param name="goList"></param>
        public void SetHubAnchor(GameObject[] goList)
        {
            // 初期化
            if (hubAnchors.Count != goList.Length)
            {
                hubAnchors.Clear();
                for (var i = 0; i < goList.Length; i++)
                {
                    hubAnchors.Add(new HubAnchor(i.ToString()));
                }
            }

            // 0番目をCenterに指定
            var savedCount = 0;

            for (var i = 0; i < goList.Length; i++)
            {
                hubAnchors[i].SetRootHubAndRootObjectTransform(goList[i].transform, goList[0].transform, anchor);
                // アンカー保存処理
                hubAnchors[i].SavedHubAnchor += () =>
                {
                    savedCount++;
                    if (savedCount == goList.Length)
                    {
                        // アンカーデータ保存
                        var list = new List <JsonHubAnchor>();
                        for (var j = 0; j < hubAnchors.Count; j++)
                        {
                            list.Add(hubAnchors[j].GetJsonHubAnchor());
                        }

                        JsonAnchorData.SaveAnchorData(list);

                        // アンカー再設置
                        isLoadedAnchor = false;
                        var loadedCount = 0;
                        for (var j = 0; j < list.Count; j++)
                        {
                            hubAnchors[j].LoadedHubAnchor += () =>
                            {
                                loadedCount++;
                                if (loadedCount == list.Count)
                                {
                                    isLoadedAnchor = true;
                                }
                            };
                            hubAnchors[j].LoadAnchorData(anchor, list[j]);
                        }
                    }
                };
            }
        }