public override void ResetDefault()
		{
			if (defaultSetting == null) return;

			CachedRectTransform.anchoredPosition = defaultSetting.anchoredPosition;
			CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, defaultSetting.size.x);
			CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, defaultSetting.size.y);
		}
Ejemplo n.º 2
0
        public void DoReposition()
        {
            mNeedReposition = false;
            int count = mTreeItemList.Count;

            mContentTotalHeight = 0;
            mContentTotalWidth  = 0;
            CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, 0);
            if (IsRootTree == false)
            {
                CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, TreeListMaxWidth);
            }
            if (count == 0)
            {
                return;
            }
            float itemPadding = 0;

            if (ParentTreeItem != null)
            {
                itemPadding = ParentTreeItem.ChildTreeItemPadding;
            }
            else
            {
                itemPadding = RootTreeView.ItemPadding;
            }
            float curY = 0;

            if (ParentTreeItem != null)
            {
                curY = -ParentTreeItem.ChildTreeListPadding;
            }
            for (int i = 0; i < count; ++i)
            {
                TreeViewItem tItem = mTreeItemList[i];
                tItem.CachedRectTransform.localPosition = new Vector3(0, curY, 0);
                tItem.Reposition();

                curY = curY - tItem.TotalHeight - itemPadding;
                if (tItem.MaxWidth > mContentTotalWidth)
                {
                    mContentTotalWidth = tItem.MaxWidth;
                }
            }
            mContentTotalHeight = -curY - itemPadding;
            CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, mContentTotalHeight);
            if (IsRootTree)
            {
                CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, mContentTotalWidth);
            }
        }
		void Update()
		{
			if (defaultSetting==null)
			{
				InitDefaultSetting();
			}
			if (HasChanged)
			{
				Setting setting = settingList.Find(x => x.language == currentLanguage);
				if (setting == null)
				{
					setting = defaultSetting;
				}
				if (setting == null) return;

				CachedRectTransform.anchoredPosition = setting.anchoredPosition;
				CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, setting.size.x);
				CachedRectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, setting.size.y);
			}
		}