summaryrefslogtreecommitdiff
path: root/Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-22 23:30:02 +0800
committerchai <chaifix@163.com>2020-10-22 23:30:02 +0800
commit917e9e0b320775634dc2e710f7deac74fd0822f0 (patch)
tree637f3cccc80e7738c8a077fa3ff59218b8b18ee8 /Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs
parent8268e4e308bd110dfea4ad849a7ff74e66951349 (diff)
* amplify shader editor
Diffstat (limited to 'Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs')
-rw-r--r--Assets/MaterializeFX/MaterializationFX/Scripts/Utils/DemoPrefabController.cs41
1 files changed, 41 insertions, 0 deletions
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