2024-12-20 10:10:19 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Unity.VisualScripting;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class Panel2 : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private Toggle toggle;//<2F><>ɫ<EFBFBD><C9AB><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private Button follow;//<2F><><EFBFBD><EFBFBD><EFBFBD>鰴ť
|
|
|
|
|
private Button end;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
|
|
|
|
|
private Dropdown dropdown;
|
|
|
|
|
private int optionCount; // <20><><EFBFBD>ڴ洢<DAB4><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>Dropdownѡ<6E><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD>
|
|
|
|
|
|
|
|
|
|
private List<Camera> characterCameras; // <20>洢ÿ<E6B4A2><C3BF><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
|
|
|
|
|
private List<GameObject> nameImage; // <20>洢<EFBFBD><E6B4A2><EFBFBD>н<EFBFBD>ɫ<EFBFBD><C9AB>ǩ<EFBFBD><C7A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
private GameObject peopleposition;
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
toggle=transform.Find("right/under/Toggle").GetComponent<Toggle>();
|
|
|
|
|
toggle.onValueChanged.AddListener(OnToggleValueChanged);
|
|
|
|
|
toggle.isOn = true;
|
|
|
|
|
dropdown =transform.Find("left/Dropdown").GetComponent<Dropdown>();
|
|
|
|
|
follow=transform.Find("left/Follow").GetComponent<Button>();
|
|
|
|
|
follow.onClick.AddListener(FollowBtn);
|
|
|
|
|
end = transform.Find("left/btn_enddrill").GetComponent<Button>();
|
|
|
|
|
end.onClick.AddListener(EndBtn);
|
|
|
|
|
|
2024-12-23 14:46:56 +08:00
|
|
|
|
peopleposition = GameObject.Find("peopleposition").gameObject;
|
2024-12-20 10:10:19 +08:00
|
|
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> Button <20><><EFBFBD><EFBFBD>
|
|
|
|
|
nameImage = new List<GameObject>();
|
|
|
|
|
foreach (Transform child in peopleposition.transform)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>"bg"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Transform bgTransform = child.Find("nameImage");
|
|
|
|
|
if (bgTransform != null)
|
|
|
|
|
{
|
|
|
|
|
nameImage.Add(bgTransform.gameObject);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Ĭ<><C4AC>ִ<EFBFBD><D6B4>һ<EFBFBD><D2BB><EFBFBD>л<EFBFBD>
|
|
|
|
|
OnToggleValueChanged(toggle.isOn);
|
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ͷ<EFBFBD>б<EFBFBD>
|
|
|
|
|
//characterCameras = new List<Camera>();
|
|
|
|
|
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ͷ<EFBFBD>ǹ<EFBFBD><C7B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ "CharacterCamera1", "CharacterCamera2", <20>ȵȵĶ<C8B5><C4B6><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//for (int i = 1; i <= optionCount; i++)
|
|
|
|
|
//{
|
|
|
|
|
// GameObject characterCameraObject = GameObject.Find("CharacterCamera" + i);
|
|
|
|
|
// if (characterCameraObject != null)
|
|
|
|
|
// {
|
|
|
|
|
// characterCameras.Add(characterCameraObject.GetComponent<Camera>());
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Dropdownѡ<6E><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
|
|
|
|
|
public void SetOptionCount(int count)
|
|
|
|
|
{
|
|
|
|
|
optionCount = count;
|
|
|
|
|
dropdown.ClearOptions();
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
var options = new System.Collections.Generic.List<string>();
|
|
|
|
|
for (int i = 0; i < optionCount; i++)
|
|
|
|
|
{
|
|
|
|
|
options.Add("<22><>ɫ " + (i + 1)); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"<22><>ɫ 1"<22><>"<22><>ɫ 2"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>ɰ<EFBFBD><C9B0><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
dropdown.AddOptions(options);
|
|
|
|
|
}
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// Toggle״̬<D7B4>仯ʱ<E4BBAF><CAB1><EFBFBD>õķ<C3B5><C4B7><EFBFBD>
|
|
|
|
|
void OnToggleValueChanged(bool isOn)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>Toggle<6C><65>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"nameImage"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
foreach (var bgObject in nameImage)
|
|
|
|
|
{
|
|
|
|
|
bgObject.SetActive(isOn); // <20><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void FollowBtn()
|
|
|
|
|
{
|
|
|
|
|
//<2F>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ,<2C><>ʾ<EFBFBD><CABE>ɫ<EFBFBD>ӽ<EFBFBD>
|
|
|
|
|
//peopleposition.SetActive(false);
|
|
|
|
|
int selectedIndex = dropdown.value;
|
|
|
|
|
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ" + (selectedIndex+1) + "<22>ӽ<EFBFBD>");
|
|
|
|
|
|
|
|
|
|
// <20>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
//SwitchToCharacterCamera(selectedIndex);
|
|
|
|
|
|
|
|
|
|
Game.uiManager.CloseUI("Panel1_2");
|
|
|
|
|
Game.uiManager.ShowUI<Image>("Panel1_3");
|
|
|
|
|
}
|
|
|
|
|
// <20>л<EFBFBD><D0BB><EFBFBD>ѡ<EFBFBD>еĽ<D0B5>ɫ<EFBFBD>ӽ<EFBFBD>
|
|
|
|
|
void SwitchToCharacterCamera(int index)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
foreach (var camera in characterCameras)
|
|
|
|
|
{
|
|
|
|
|
if (camera != null)
|
|
|
|
|
{
|
|
|
|
|
camera.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ѡ<EFBFBD>н<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ
|
|
|
|
|
if (index >= 0 && index < characterCameras.Count)
|
|
|
|
|
{
|
|
|
|
|
Camera selectedCamera = characterCameras[index];
|
|
|
|
|
if (selectedCamera != null)
|
|
|
|
|
{
|
|
|
|
|
selectedCamera.gameObject.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void EndBtn()
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ
|
|
|
|
|
Game.uiManager.ShowUI<Image>("PoPhost");
|
2024-12-23 14:46:56 +08:00
|
|
|
|
}
|
2024-12-20 10:10:19 +08:00
|
|
|
|
}
|