海淀天下城电子沙盘单机版
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.

153 lines
4.3 KiB

4 years ago
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
/// <summary>
/// 文字设置面板
/// </summary>
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;
/// <summary>
/// 记录颜色拾取圈的位置
/// </summary>
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<UIPlanInstanceText>();
instance.Init();
}
return instance;
}
}
public void Init()
{
Text_Scale = transform.Find("Text_Scale").GetComponent<Text>();
Slider_SetTextSize = transform.Find("Slider_SetTextSize").GetComponent<Slider>();
mainColor = transform.Find("ColorPicker").Find("MainColor");
InputField_Text = transform.Find("InputField_Text").GetComponent<InputField>();
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();
}
///// <summary>
///// 打开面板
///// </summary>
//public override void OpenPanel()
//{
// if (!this.gameObject.activeInHierarchy)
// this.gameObject.SetActive(true);
// LoadObjData();
//}
/// <summary>
/// 重置面板
/// </summary>
public override void LoadObjData(GameObject chooseObj)
{
//chooseObj = SelectedObjs.selectedObj;
gameObject.SetActive(true);
var type = chooseObj.GetComponent<TextControl>();
ChooseObj = chooseObj;
Text_Scale.text = type.Scale.ToString();
Slider_SetTextSize.value = type.Scale;
mainColor.GetComponent<MainColorTape>().Color = chooseObj.GetComponent<TextControl>().Color;
InputField_Text.text = type.InputField == null ? "文字设置" : type.InputField;
}
public override void ResetData(GameObject dataObj)
{
dataObj.GetComponent<TextControl>().Revocation();
}
/// <summary>
/// 设置文本
/// </summary>
/// <param name="inputFiled"></param>
public void SetText(string inputFiled)
{
ChooseObj.GetComponent<TextControl>().SetText(inputFiled);
}
/// <summary>
/// 设置颜色
/// </summary>
/// <param name="color"></param>
public void SetColor(Color color)
{
if(ChooseObj)
ChooseObj.GetComponent<TextControl>().SetColor(color);
}
/// <summary>
/// 设置大小
/// </summary>
/// <param name="value"></param>
public void SetSize(float value)
{
ChooseObj.GetComponent<TextControl>().SetScale(value);
Text_Scale.text = value.ToString();
}
/// <summary>
/// 确认
/// </summary>
public void Confirm()
{
gameObject.SetActive(false);
ChooseObj.GetComponent<TextControl>().Confirm();
colorNoniusPos = colorNonius.localPosition;
}
/// <summary>
/// 取消
/// </summary>
public void Cancel()
{
//Revocation();
gameObject.SetActive(false);
}
public void Revocation()
{
colorNonius.localPosition = colorNoniusPos;
ChooseObj.GetComponent<TextControl>().Revocation();
LoadObjData(ChooseObj);
}
public override void EditorRight()
{
}
}