using SpringGUI; using UnityEngine; using UnityEngine.UI; //Author:ZCG //CreatTime:12/15/2017 /// /// 区域设置面板 /// public class UIPlanSetArea : BaseInstanceMono { private static UIPlanSetArea instance; //private new GameObject chooseObj; //private GameObject oldChooseObj; //[SerializeField] private InputField Input_Name; //[SerializeField] private Slider Slider_SetHigh; //[SerializeField] private Transform mainColor; //[SerializeField] private Text Text_High; /// /// 记录颜色拾取圈的位置 /// private Vector2 colorNoniusPos; //颜色拾取圈 private RectTransform colorNonius; private GameObject chooseObj; public static UIPlanSetArea Instance { get { if (instance == null) { GameObject obj = Resources.Load("Prefab/Tool/UIPlanSetArea"); GameObject clone = Instantiate(obj, GameObject.Find("Canvas").transform); clone.transform.SetAsFirstSibling(); clone.SetActive(false); instance = clone.GetComponent(); instance.Init(); } return instance; } } private void Init() { Slider_SetHigh = transform.Find("SetHight").GetComponent(); Input_Name = transform.Find("InputField_Name").GetComponent(); mainColor = transform.Find("ColorPicker").Find("MainColor"); Text_High = transform.Find("Text_High").GetComponent(); colorNonius = transform.Find("ColorPicker").Find("ColorPalette").Find("ColorNonius") as RectTransform; colorNoniusPos = colorNonius.localPosition; } ///// ///// 打开面板 ///// //public override void OpenPanel() //{ // if (!this.gameObject.activeInHierarchy) // this.gameObject.SetActive(true); //} /// /// 重置面板 /// public override void LoadObjData(GameObject obj) { //chooseObj = SelectedObjs.selectedObj; chooseObj = obj; var type = chooseObj.GetComponent(); mainColor.GetComponent().Color = type.Color; Slider_SetHigh.value = type.High; Input_Name.text = type.Name; Text_High.text = type.High.ToString(); gameObject.SetActive(true); } public override void ResetData(GameObject dataObj) { dataObj.GetComponent().Revocation(); } public void SetColor(Color value) { if (chooseObj) chooseObj.GetComponent().SetColor(value); } public void SetName(string value) { chooseObj.GetComponent().SetName(value); } public void SetHigh(float value) { chooseObj.GetComponent().SetHigh(value); Text_High.text = value.ToString(); } /// /// 确认 /// public void Confirm() { gameObject.SetActive(false); chooseObj.GetComponent().Confirm(); colorNoniusPos = colorNonius.localPosition; } /// /// 取消 /// public void Cancel() { //Revocation(); gameObject.SetActive(false); } public void Revocation() { colorNonius.localPosition = colorNoniusPos; chooseObj.GetComponent().Revocation(); LoadObjData(chooseObj); } public override void EditorRight() { } }