summaryrefslogtreecommitdiff
path: root/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2020-10-23 13:08:43 +0800
committerchai <chaifix@163.com>2020-10-23 13:08:43 +0800
commitb82da95b5181ac8bbae38efb13e950d5e88a4caa (patch)
tree48a6f3269276484bbc7cfc95f0651f40a2176aa1 /Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs
parent917e9e0b320775634dc2e710f7deac74fd0822f0 (diff)
*移动amplify shader editor到third party目录
Diffstat (limited to 'Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs')
-rw-r--r--Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs41
1 files changed, 41 insertions, 0 deletions
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