From 917e9e0b320775634dc2e710f7deac74fd0822f0 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 22 Oct 2020 23:30:02 +0800 Subject: * amplify shader editor --- .../Scripts/Utils/DemoPrefabController.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs (limited to 'Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs') diff --git a/Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs b/Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs new file mode 100644 index 00000000..73316f82 --- /dev/null +++ b/Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs @@ -0,0 +1,41 @@ +using UnityEngine; + +namespace MaterializationFX.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