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.
42 lines
934 B
42 lines
934 B
4 years ago
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
|
||
|
public class RoleItem : MonoBehaviour {
|
||
|
|
||
|
private Toggle toggle;
|
||
|
private string roleName;
|
||
|
private Text roleText;
|
||
|
private RoleSelectPanel roleSelect;
|
||
|
private void Awake()
|
||
|
{
|
||
|
toggle = GetComponent<Toggle>();
|
||
|
roleText = transform.Find("Label").GetComponent<Text>();
|
||
|
}
|
||
|
// Use this for initialization
|
||
|
void Start ()
|
||
|
{
|
||
|
roleSelect = transform.GetComponentInParent<RoleSelectPanel>();
|
||
|
toggle.onValueChanged.AddListener(SetRole);
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void Update () {
|
||
|
|
||
|
}
|
||
|
public void SetItem(string role)
|
||
|
{
|
||
|
roleText.text = role;
|
||
|
roleName = role;
|
||
|
}
|
||
|
private void SetRole(bool isOn)
|
||
|
{
|
||
|
if (isOn)
|
||
|
{
|
||
|
roleSelect.roleName = roleName;
|
||
|
}
|
||
|
}
|
||
|
}
|