Пример #1
0
        private void Materialize(VirtualGameObject parent, Tokenizer.OnMaterializeDelegate onMaterializeDel)
        {
            switch (this.tag)
            {
            case Tag.ROOT: {
                // do nothing.
                break;
            }

            case Tag.BR: {
                // has no child. no visual. do nothing.
                break;
            }

            default: {
                this._gameObject = MaterializeTagContent();
                this._gameObject.transform.SetParent(parent._gameObject.transform, false);
                var rectTrans = this._gameObject.GetComponent <RectTransform>();
                if (rectTrans == null)
                {
                    return;
                }

                // set position. convert layout position to uGUI position system.
                rectTrans.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, -rectTransform.anchoredPosition.y);
                // Debug.LogError("materialize rectTrans.anchoredPosition:" + rectTrans.anchoredPosition);
                rectTrans.sizeDelta = rectTransform.sizeDelta;

                break;
            }
            }

            foreach (var child in this.transform.GetChildlen())
            {
                child.Materialize(this, onMaterializeDel);
            }

            onMaterializeDel(this._gameObject, this.tag, this.depth, new Dictionary <KV_KEY, string>(this.keyValueStore));
        }
Пример #2
0
        /**
         *      return generated game object.
         */
        public GameObject MaterializeRoot(string viewName, Vector2 viewPort, Tokenizer.OnLayoutDelegate onLayoutDel, Tokenizer.OnMaterializeDelegate onMaterializeDel)
        {
            var rootHandlePoint = new HandlePoint(0, 0, viewPort.x, viewPort.y);

            // 事前計算、ここでコンテンツの一覧を返すようにすればいいかな。要素単位で。
            Layout(this, rootHandlePoint, onLayoutDel, t => {});


            this._gameObject = new GameObject(viewName + Tag.ROOT.ToString());

            this.rootInstance = this._gameObject.AddComponent <InformationRootMonoBehaviour>();
            var rectTrans = this._gameObject.AddComponent <RectTransform>();

            rectTrans.anchorMin = Vector2.up;
            rectTrans.anchorMax = Vector2.up;
            rectTrans.pivot     = Vector2.up;
            rectTrans.position  = Vector2.zero;
            rectTrans.sizeDelta = viewPort;

            // 範囲指定してGOを充てる、ということがしたい。
            Materialize(this, onMaterializeDel);

            return(this._gameObject);
        }