using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using SpringGUI;
using AX.MessageSystem;
//Author:ZCG
//CreatTime:12/14/2017
///
/// 文字设置面板
///
public class UIPlanInstanceText : BaseInstanceMono
{
private static UIPlanInstanceText instance;
//private GameObject oldChooseObj;
private Text Text_Scale;
private Slider Slider_SetTextSize;
private Transform mainColor;
private InputField InputField_Text;
///
/// 记录颜色拾取圈的位置
///
private Vector2 colorNoniusPos;
//颜色拾取圈
private RectTransform colorNonius;
//private void Start()
//{
// instance = this;
// Init();
// gameObject.SetActive(false);
//}
public static UIPlanInstanceText Instance
{
get
{
if (instance == null)
{
Transform canvas = GameObject.Find("Canvas").transform;
GameObject panel = Instantiate(Resources.Load("Prefab/Tool/UIPlanInstanceText") as GameObject, canvas);
instance = panel.GetComponent();
instance.Init();
}
return instance;
}
}
public void Init()
{
Text_Scale = transform.Find("Text_Scale").GetComponent();
Slider_SetTextSize = transform.Find("Slider_SetTextSize").GetComponent();
mainColor = transform.Find("ColorPicker").Find("MainColor");
InputField_Text = transform.Find("InputField_Text").GetComponent();
colorNonius = transform.Find("ColorPicker").Find("ColorPalette").Find("ColorNonius") as RectTransform;
colorNoniusPos = colorNonius.localPosition;
}
private void Start()
{
MessageDispatcher.AddListener("SelectChange", selctchange);
}
private void OnDestroy()
{
MessageDispatcher.RemoveListener("SelectChange", selctchange);
}
private void selctchange(IMessage obj)
{
Cancel();
}
/////
///// 打开面板
/////
//public override void OpenPanel()
//{
// if (!this.gameObject.activeInHierarchy)
// this.gameObject.SetActive(true);
// LoadObjData();
//}
///
/// 重置面板
///
public override void LoadObjData(GameObject chooseObj)
{
//chooseObj = SelectedObjs.selectedObj;
gameObject.SetActive(true);
var type = chooseObj.GetComponent();
ChooseObj = chooseObj;
Text_Scale.text = type.Scale.ToString();
Slider_SetTextSize.value = type.Scale;
mainColor.GetComponent().Color = chooseObj.GetComponent().Color;
InputField_Text.text = type.InputField == null ? "文字设置" : type.InputField;
}
public override void ResetData(GameObject dataObj)
{
dataObj.GetComponent().Revocation();
}
///
/// 设置文本
///
///
public void SetText(string inputFiled)
{
ChooseObj.GetComponent().SetText(inputFiled);
}
///
/// 设置颜色
///
///
public void SetColor(Color color)
{
if(ChooseObj)
ChooseObj.GetComponent().SetColor(color);
}
///
/// 设置大小
///
///
public void SetSize(float value)
{
ChooseObj.GetComponent().SetScale(value);
Text_Scale.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()
{
}
}