From b82da95b5181ac8bbae38efb13e950d5e88a4caa Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 23 Oct 2020 13:08:43 +0800 Subject: =?UTF-8?q?*=E7=A7=BB=E5=8A=A8amplify=20shader=20editor=E5=88=B0th?= =?UTF-8?q?ird=20party=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scripts/Utils/DemoPrefabController.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs (limited to 'Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs') diff --git a/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs new file mode 100644 index 00000000..d1c108bb --- /dev/null +++ b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace Assets.MaterializeFX.Scripts.Utils +{ + internal sealed class DemoPrefabController : MonoBehaviour + { + public int StartNum; + public GameObject[] Prefabs; + + private GameObject _currentInstance; + private int _currentPrefabNum; + + public void Next() + { + if (Prefabs.Length == 0) + return; + + _currentPrefabNum++; + if (_currentPrefabNum >= Prefabs.Length) + _currentPrefabNum = 0; + + ChangePrefab(_currentPrefabNum); + } + + private void Start() + { + _currentPrefabNum = StartNum; + + ChangePrefab(_currentPrefabNum); + } + + private void ChangePrefab(int num) + { + if (_currentInstance != null) + Destroy(_currentInstance); + var newPrefab = Prefabs[num]; + _currentInstance = Instantiate(newPrefab, newPrefab.transform.position, newPrefab.transform.transform.rotation); + _currentInstance.SetActive(true); + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0