64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Panel3 : MonoBehaviour
|
|
{
|
|
private Button cancel;
|
|
private Button online;//目前在线离线状况弹窗按钮
|
|
private Button follow;//跟随查按钮
|
|
private Dropdown dropdown;
|
|
private int optionCount; // 用于存储传入的确定Dropdown选项数量的参数
|
|
private GameObject peopleposition;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
cancel=transform.Find("left/btn_enddrill").GetComponent<Button>();
|
|
cancel.onClick.AddListener(OnCancelBtn);
|
|
online=transform.Find("onlineBtn").GetComponent <Button>();
|
|
online.onClick.AddListener(OnClickOnlineBtn);
|
|
dropdown=transform.Find("left/Dropdown").GetComponent<Dropdown>();
|
|
follow = transform.Find("left/Follow").GetComponent<Button>();
|
|
follow.onClick.AddListener(FollowBtn);
|
|
peopleposition = GameObject.Find("peopleposition").gameObject;
|
|
peopleposition.SetActive(false);
|
|
}
|
|
// 用于外部传入参数来设置Dropdown选项数量的方法
|
|
public void SetOptionCount(int count)
|
|
{
|
|
optionCount = count;
|
|
dropdown.ClearOptions();
|
|
// 创建一个临时的字符串列表用于添加选项内容
|
|
var options = new System.Collections.Generic.List<string>();
|
|
for (int i = 0; i < optionCount; i++)
|
|
{
|
|
options.Add("角色 " + (i + 1)); // 简单添加类似"角色 1"、"角色 2"这样的选项名称,可按需修改
|
|
}
|
|
dropdown.AddOptions(options);
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
void OnCancelBtn()
|
|
{
|
|
peopleposition.gameObject.SetActive(true);
|
|
//返回上帝视角界面
|
|
Game.uiManager.ShowUI<Image>("Panel1_2");
|
|
Game.uiManager.CloseUI("Panel1_3");
|
|
}
|
|
void OnClickOnlineBtn()
|
|
{
|
|
//人员在线状态,弹出窗口
|
|
Game.uiManager.ShowUI<Image>("Panel");
|
|
}
|
|
void FollowBtn()
|
|
{
|
|
//转化角色视角
|
|
int selectedIndex = dropdown.value;
|
|
Debug.Log("进入角色" + (selectedIndex+1) + "视角");
|
|
}
|
|
}
|