海淀天下城电子沙盘单机版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

127 lines
3.5 KiB

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