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.
61 lines
1.4 KiB
61 lines
1.4 KiB
3 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
//Author:YHD
|
||
|
public class NodeItem_SL : MonoBehaviour {
|
||
|
|
||
|
private TreeViewData nodeData;
|
||
|
private Text text;
|
||
|
private Toggle toggle;
|
||
|
private GameObject image;
|
||
|
public List<string> tags;//Tips:编辑节点的Tag后,请将此变量赋值为null,重新刷新tag
|
||
|
// Use this for initialization
|
||
|
void Awake () {
|
||
|
text = TransformHelper.FindChild(transform, "Text").GetComponent<Text>();
|
||
|
toggle = GetComponent<Toggle>();
|
||
|
toggle.onValueChanged.AddListener(onValueChange);
|
||
|
image= TransformHelper.FindChild(transform, "Image").gameObject;
|
||
|
}
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
toggle.group = transform.parent.GetComponent<ToggleGroup>();
|
||
|
}
|
||
|
|
||
|
private void onValueChange(bool isOn)
|
||
|
{
|
||
|
if (isOn)
|
||
|
{
|
||
|
NodeSecondLevelControl.Instance.SelectCurNode(this);
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
NodeSecondLevelControl.Instance.SelectCurNode(null, false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
|
||
|
}
|
||
|
|
||
|
public void SetData(TreeViewData data)
|
||
|
{
|
||
|
nodeData = data;
|
||
|
text.text = data.Name;
|
||
|
toggle.isOn = false;
|
||
|
}
|
||
|
public TreeViewData GetData()
|
||
|
{
|
||
|
return nodeData;
|
||
|
}
|
||
|
|
||
|
public void SetToggle()
|
||
|
{
|
||
|
toggle.isOn = true;
|
||
|
}
|
||
|
}
|