using Cysharp.Threading.Tasks; using PMaker.DependencyInjection; using PMaker.Extension; using System.Threading; using UnityEngine; public class ModelViewLogic : InstanceMonobehaviour { public Transform freeView; public Transform modelRoot; private GameObject _current; public ObjectCameraRotate logic; private void Reset() { freeView = this.transform.Find("FreeView"); modelRoot = this.transform.Find("Target"); logic = transform.GetComponentInChildren(); } public async UniTask InitAsync(CancellationToken cancellationToken) { this.HideAll(); await UniTask.Yield(cancellationToken); } public void ShowModel(string name) { this.freeView.gameObject.SetActive(true); _current?.SetActive(false); _current = modelRoot.Find(name).gameObject; _current?.SetActive(true); } public void ShowModel(int index) { this.freeView.gameObject.SetActive(true); _current?.SetActive(false); _current = modelRoot.GetChild(index).gameObject; _current?.SetActive(true); } public GameObject GetCurrent() { return this._current; } public void ResetView() { freeView.localRotation = Quaternion.identity; this.logic.ResetDistance(); } public void SetRotateActive(bool value) { this.logic.enabled = value; } public void SetRotate(Vector3 target) { this.freeView.transform.localEulerAngles = target; } public Vector3 GetRotate() { //Debug.Log(freeView.transform.localEulerAngles); return this.freeView.transform.localEulerAngles; } public void HideAll() { foreach (var item in this.modelRoot.Children()) { item.gameObject.SetActive(false); } this.freeView.gameObject.SetActive(false); } }