123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class DrawControl : MonoBehaviour
- {
- public Toggle arrowToggle_;
- public Toggle textToggle_;
- public Toggle brushToggle_;
- public Toggle targetToggle_;
- public static DrawScript drawScript_;
- public void Clear()
- {
- drawScript_.Clear();
- arrowToggle_.isOn = false;
- textToggle_.isOn = false;
- brushToggle_.isOn = false;
- targetToggle_.isOn = false;
- }
- // Use this for initialization
- public void Init()
- {
- arrowToggle_.onValueChanged.AddListener(OnArrowToggleValueChanged);
- textToggle_.onValueChanged.AddListener(OnTextToggleValueChanged);
- brushToggle_.onValueChanged.AddListener(OnBrushToggleValueChanged);
- targetToggle_.onValueChanged.AddListener(OnTargetToggleValueChanged);
- }
- private void OnArrowToggleValueChanged(bool isOn)
- {
- ColorBlock cb = arrowToggle_.colors;
- if (isOn)
- {
- cb.normalColor = Color.gray;
- cb.highlightedColor = Color.gray;
- textToggle_.isOn = false;
- brushToggle_.isOn = false;
- targetToggle_.isOn = false;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.ARROW;
- }
- else
- {
- cb.normalColor = Color.white;
- cb.highlightedColor = Color.white;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.NO_DRAW;
- }
- arrowToggle_.colors = cb;
- }
- private void OnTextToggleValueChanged(bool isOn)
- {
- ColorBlock cb = textToggle_.colors;
- if (isOn)
- {
- cb.normalColor = Color.gray;
- cb.highlightedColor = Color.gray;
- arrowToggle_.isOn = false;
- brushToggle_.isOn = false;
- targetToggle_.isOn = false;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.TEXT;
- }
- else
- {
- cb.normalColor = Color.white;
- cb.highlightedColor = Color.white;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.NO_DRAW;
- }
- textToggle_.colors = cb;
- }
- private void OnBrushToggleValueChanged(bool isOn)
- {
- ColorBlock cb = brushToggle_.colors;
- if (isOn)
- {
- cb.normalColor = Color.gray;
- cb.highlightedColor = Color.gray;
- arrowToggle_.isOn = false;
- textToggle_.isOn = false;
- targetToggle_.isOn = false;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.PAINTBRUSH;
- }
- else
- {
- cb.normalColor = Color.white;
- cb.highlightedColor = Color.white;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.NO_DRAW;
- }
- brushToggle_.colors = cb;
- }
- private void OnTargetToggleValueChanged(bool isOn)
- {
- ColorBlock cb = targetToggle_.colors;
- if (isOn)
- {
- cb.normalColor = Color.gray;
- cb.highlightedColor = Color.gray;
- arrowToggle_.isOn = false;
- textToggle_.isOn = false;
- brushToggle_.isOn = false;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.TARGET;
- }
- else
- {
- cb.normalColor = Color.white;
- cb.highlightedColor = Color.white;
- drawScript_.DrawMode = DrawScript.DRAW_MODE.NO_DRAW;
- }
- targetToggle_.colors = cb;
- }
- }
|