using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; /// /// 负责删除、编辑、添加脚本的位置匹配 /// public class AdjustIcon : MonoBehaviour { RectTransform rectEdit; RectTransform rectAdd; RectTransform rectDel; TreeViewItem__ treeView; // Use this for initialization void Start () { rectEdit=TransformHelper.FindChild(transform,"TreeViewButtonEdit").GetComponent(); rectAdd = TransformHelper.FindChild(transform, "TreeViewButtonAdd").GetComponent(); rectDel = TransformHelper.FindChild(transform, "TreeViewButtonDelete").GetComponent(); treeView = GetComponent(); InitOrigPos(); } void InitOrigPos() { switch (treeView.GetHierarchy()) { case 1: SetPos(new Vector2(101.5f,0.2f),new Vector2(119,0.2f),new Vector2(136.5f,0.2f)); break; case 2: SetPos(new Vector2(87.4f,0), new Vector2(104.9f, 0), new Vector2(122.4f, 0)); break; case 3: SetPos(new Vector2(73.41f,0), new Vector2(90.91f,0), new Vector2(107.9f,0)); break; case 4: SetPos(new Vector2(59.41f, 0), new Vector2(76.91f, 0), new Vector2(93.9f, 0)); break; default: break; } } void SetPos(Vector2 vecEdit, Vector2 vecAdd, Vector2 vecDel) { rectEdit.anchoredPosition = vecEdit; rectAdd.anchoredPosition = vecAdd; rectDel.anchoredPosition = vecDel; } }