diff options
Diffstat (limited to 'Assets/ThirdParty/MaterializeFX/Scripts/Utils')
6 files changed, 175 insertions, 0 deletions
diff --git a/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoInputConrtoller.cs b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoInputConrtoller.cs new file mode 100644 index 00000000..f5b2c26f --- /dev/null +++ b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoInputConrtoller.cs @@ -0,0 +1,37 @@ +using UnityEngine;
+
+namespace Assets.MaterializeFX.Scripts.Utils
+{
+ internal sealed class DemoInputConrtoller : MonoBehaviour
+ {
+ private const string SpaceButton = "space";
+ private const string LightButton = "f";
+ private DemoPrefabController _demoPrefabController;
+
+ public Light Light;
+
+ public void EnableLigh()
+ {
+ Light.enabled = true;
+ }
+
+ public void DisableLight()
+ {
+ Light.enabled = false;
+ }
+
+ private void Start()
+ {
+ _demoPrefabController = GetComponent<DemoPrefabController>();
+ }
+
+ private void Update()
+ {
+ if (Input.GetKeyDown(SpaceButton))
+ _demoPrefabController.Next();
+
+ if (Input.GetKeyDown(LightButton))
+ Light.enabled = !Light.enabled;
+ }
+ }
+}
\ No newline at end of file diff --git a/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoInputConrtoller.cs.meta b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoInputConrtoller.cs.meta new file mode 100644 index 00000000..73ac01ca --- /dev/null +++ b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoInputConrtoller.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 6a769f5ec192b024985c56e36956f614 +timeCreated: 1504459121 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: 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 diff --git a/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs.meta b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs.meta new file mode 100644 index 00000000..5f29197f --- /dev/null +++ b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/DemoPrefabController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: b1a784e5c50cf8d4791732b4911f7e65 +timeCreated: 1504459134 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ThirdParty/MaterializeFX/Scripts/Utils/MouseOrbitController.cs b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/MouseOrbitController.cs new file mode 100644 index 00000000..e2f91048 --- /dev/null +++ b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/MouseOrbitController.cs @@ -0,0 +1,58 @@ +using UnityEngine;
+
+namespace Assets.MaterializeFX.Scripts.Utils
+{
+ internal sealed class MouseOrbitController : MonoBehaviour
+ {
+ public Transform Target;
+ public float Distance = 5.0f;
+ public float XSpeed = 120.0f;
+ public float YSpeed = 120.0f;
+
+ public float YMinLimit = 20f;
+ public float YMaxLimit = 80f;
+
+ public float DistanceMin = .5f;
+ public float DistanceMax = 15f;
+
+ private float _x;
+ private float _y;
+
+ private void Start()
+ {
+ var angles = transform.eulerAngles;
+ _x = angles.y;
+ _y = angles.x;
+ }
+
+ private void LateUpdate()
+ {
+ if (!Input.GetMouseButton(0))
+ return;
+
+ _x += Input.GetAxis("Mouse X") * XSpeed * Distance * 0.02f;
+ _y -= Input.GetAxis("Mouse Y") * YSpeed * 0.02f;
+
+ _y = ClampAngle(_y, YMinLimit, YMaxLimit);
+
+ var rotation = Quaternion.Euler(_y, _x, 0);
+
+ Distance -= Input.GetAxis("Mouse ScrollWheel") * 5;
+
+ var negDistance = new Vector3(0.0f, 0.0f, -Distance);
+ var position = rotation * negDistance + Target.position;
+
+ transform.rotation = rotation;
+ transform.position = position;
+ }
+
+ private static float ClampAngle(float angle, float min, float max)
+ {
+ if (angle < -360F)
+ angle += 360F;
+ if (angle > 360F)
+ angle -= 360F;
+ return Mathf.Clamp(angle, min, max);
+ }
+ }
+}
diff --git a/Assets/ThirdParty/MaterializeFX/Scripts/Utils/MouseOrbitController.cs.meta b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/MouseOrbitController.cs.meta new file mode 100644 index 00000000..b6ac3ab0 --- /dev/null +++ b/Assets/ThirdParty/MaterializeFX/Scripts/Utils/MouseOrbitController.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 04f1caafe23156a438ca1d322d70a4ac +timeCreated: 1516131563 +licenseType: Store +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |