123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- //------------------------------------------------------------
- // Game Framework
- // Copyright © 2013-2021 Jiang Yin. All rights reserved.
- // Homepage: https://gameframework.cn/
- // Feedback: mailto:ellan@gameframework.cn
- //------------------------------------------------------------
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityGameFramework.Runtime;
- namespace MetaClient
- {
- public class CustomRoleForm : UGuiForm
- {
- public Text curShow;
- public Slider curSlider;
- public Button[] btnList;
- public GameObject point;
- private EditableBodyPart curSelect = EditableBodyPart.None;
- private List<Transform> bonesTrans = new List<Transform>();
- private List<GameObject> pointList = new List<GameObject>();
- #if UNITY_2017_3_OR_NEWER
- protected override void OnOpen(object userData)
- #else
- protected internal override void OnOpen(object userData)
- #endif
- {
- base.OnOpen(userData);
- RefreshBtn();
- bonesTrans = CustomManager.Instance.testPlayer.GetBonesTrans();
- for (int i = 0; i < bonesTrans.Count; i++)
- {
- var newpoint = GameObject.Instantiate(point,transform);
- pointList.Add(newpoint);
- }
- }
- private void Start()
- {
- RefreshBtn();
- }
- private void RefreshBtn()
- {
- for (int i = 0; i < btnList.Length; i++)
- {
- var btn = btnList[i];
- btn.GetComponentInChildren<Text>().text = ((EditableBodyPart)i).ToString();
- }
- }
- #if UNITY_2017_3_OR_NEWER
- protected override void OnClose(bool isShutdown, object userData)
- #else
- protected internal override void OnClose(bool isShutdown, object userData)
- #endif
- {
- base.OnClose(isShutdown, userData);
- }
- public void ClickFaceChangeBtn(int part)
- {
- curSelect = (EditableBodyPart)part;
- RefreshSliderValue();
- }
- public void Update()
- {
- UpdateCustomBodyBoneTransShow();
- }
- private void RefreshSliderValue()
- {
- curShow.text = curSelect.ToString();
- curSlider.value = CustomManager.Instance.GetBodyBoneValue(curSelect);
- }
- public void OnSliderValueChange(float value)
- {
- if(curSelect == EditableBodyPart.None)
- {
- return;
- }
-
- GameEntry.Event.Fire(this, CustomRoleBodyEventArgs.Create(curSelect, new Vector3(value, 0, 0)));
- }
- private void UpdateCustomBodyBoneTransShow()
- {
- for (int i = 0; i < bonesTrans.Count; i++)
- {
- var point = pointList[i];
- var pos = Camera.main.WorldToScreenPoint(bonesTrans[i].position);
- point.transform.position = pos;
- }
- }
- }
- }
|