12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- using Cinemachine;
- using UnityEngine;
- using UnityEngine.UIElements;
- /* 第一次创建狗的时候选择创建或者是领养
- */
- public class CreateOrAdopt : MonoBehaviour
- {
- private Label message;
- private Button create, adopt;
- GameObject canvasPlaceholder, initDogCanvas, CreateAdoptCanvas;
- // Start is called once before the first execution of Update after the MonoBehaviour is created
- void Start()
- {
- var root = GetComponent<UIDocument>().rootVisualElement;
- message = root.Q<Label>("message");
- create = root.Q<Button>("create");
- adopt = root.Q<Button>("adopt");
- canvasPlaceholder = GameObject.Find("Canvas Placeholder");
- initDogCanvas = canvasPlaceholder.transform.Find("Init Dog Canvas").gameObject;
- CreateAdoptCanvas = canvasPlaceholder.transform.Find("Create Or Adopt Canvas").gameObject;
- create.RegisterCallback<ClickEvent>(e => CreateClick(e));
- adopt.RegisterCallback<ClickEvent>(e => AdoptClick(e));
- string textValue = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "button", "create", EnviromentSetting.languageCode });
- create.text = textValue;
- textValue = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "button", "adopt", EnviromentSetting.languageCode });
- adopt.text = textValue;
- textValue = GameTool.GetValueAtPath(EnviromentSetting.languageData, new string[] { "InitDogUI", "label", "create or adopt msg", EnviromentSetting.languageCode });
- message.text = textValue;
- if (UserProperty.dogs.Count > 0)
- {
- SwitchToCreate();
- }
- }
- // Update is called once per frame
- //void Update()
- //{
-
- //}
- void SwitchToCreate()
- {
- initDogCanvas.SetActive(true);
- CreateAdoptCanvas.SetActive(false);
- }
- void SwitchToAdopt()
- {
- // todo 扫码从别人那边继承狗
- }
- void CreateClick(ClickEvent e)
- {
- SwitchToCreate();
- }
- void AdoptClick(ClickEvent e)
- {
- SwitchToAdopt();
- }
- }
|