| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using DG.Tweening;
- public class RenderModuleCamera : MonoBehaviour
- {
- Transform sphere;
- int _mode = 1; //0:静置在桌面;1:旋转校准;
- public static RenderModuleCamera ins;
- private static int _loadCount = 0;
- public static void Load()
- {
- _loadCount++;
- if (_loadCount == 1) Instantiate(Resources.Load("RenderModuleCamera"));
- }
- public static void Unload()
- {
- _loadCount--;
- if (_loadCount < 0) _loadCount = 0;
- if (_loadCount == 0)
- {
- try { Destroy(ins.gameObject); } catch(System.Exception e) { Debug.LogError(e); }
- }
- }
- void Awake()
- {
- ins = this;
- DontDestroyOnLoad(gameObject);
- sphere = transform.Find("Sphere");
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- CloseSequence();
- }
- Sequence _sequence = null;
- void CloseSequence()
- {
- if (_sequence != null)
- {
- _sequence.Kill();
- _sequence = null;
- }
- }
- public void SetMode(int mode)
- {
- _mode = mode;
- CloseSequence();
- if (mode == 0)
- {
- sphere.localEulerAngles = new Vector3(0, 0, 180);
- sphere.gameObject.SetActive(true);
- }
- else if (mode == 1)
- {
- sphere.localEulerAngles = new Vector3(0, 0, 0);
- sphere.gameObject.SetActive(true);
- _sequence = DOTween.Sequence();
- _sequence.Append(sphere.DOLocalRotate(new Vector3(360f, 0, 0), 1.5f, RotateMode.FastBeyond360));
- _sequence.Append(sphere.DOLocalRotate(new Vector3(0, 360f, 0), 1.5f, RotateMode.FastBeyond360));
- _sequence.Append(sphere.DOLocalRotate(new Vector3(0, 0, 360f), 1.5f, RotateMode.FastBeyond360));
- _sequence.SetLoops(-1);
- }
- }
- }
|