From 22891bf59032ba88262824255a706d652031384b Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 10 Mar 2022 14:07:40 +0800 Subject: * move folder --- .../Vfx/Sword slash VFX/Demo scene/CameraHolder.cs | 163 --------------------- 1 file changed, 163 deletions(-) delete mode 100644 Assets/Art/Vfx/Sword slash VFX/Demo scene/CameraHolder.cs (limited to 'Assets/Art/Vfx/Sword slash VFX/Demo scene/CameraHolder.cs') diff --git a/Assets/Art/Vfx/Sword slash VFX/Demo scene/CameraHolder.cs b/Assets/Art/Vfx/Sword slash VFX/Demo scene/CameraHolder.cs deleted file mode 100644 index 9f77a8ca..00000000 --- a/Assets/Art/Vfx/Sword slash VFX/Demo scene/CameraHolder.cs +++ /dev/null @@ -1,163 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Runtime.Serialization.Formatters; -using System; -using UnityEngine; - -public class CameraHolder : MonoBehaviour -{ - //camera holder - public Transform Holder; - public float currDistance = 5.0f; - public float xRotate = 250.0f; - public float yRotate = 120.0f; - public float yMinLimit = -20f; - public float yMaxLimit = 80f; - public float prevDistance; - private float x = 0.0f; - private float y = 0.0f; - - [Header("GUI")] - private float windowDpi; - public GameObject[] Prefabs; - private int Prefab; - private GameObject Instance; - private float StartColor; - private float HueColor; - public Texture HueTexture; - - void Start() - { - if (Screen.dpi < 1) windowDpi = 1; - if (Screen.dpi < 200) windowDpi = 1; - else windowDpi = Screen.dpi / 200f; - var angles = transform.eulerAngles; - x = angles.y; - y = angles.x; - Counter(0); - } - - private void OnGUI() - { - if (GUI.Button(new Rect(5 * windowDpi, 5 * windowDpi, 110 * windowDpi, 35 * windowDpi), "Previous effect")) - { - Counter(-1); - } - if (GUI.Button(new Rect(120 * windowDpi, 5 * windowDpi, 110 * windowDpi, 35 * windowDpi), "Play again")) - { - Counter(0); - } - if (GUI.Button(new Rect(235 * windowDpi, 5 * windowDpi, 110 * windowDpi, 35 * windowDpi), "Next effect")) - { - Counter(+1); - } - - StartColor = HueColor; - HueColor = GUI.HorizontalSlider(new Rect(5 * windowDpi, 45 * windowDpi, 340 * windowDpi, 35 * windowDpi), HueColor, 0, 1); - GUI.DrawTexture(new Rect(5 * windowDpi, 65 * windowDpi, 340 * windowDpi, 15 * windowDpi), HueTexture, ScaleMode.StretchToFill, false, 0); - if (HueColor != StartColor) - { - int i = 0; - foreach (var ps in particleSystems) - { - var main = ps.main; - Color colorHSV = Color.HSVToRGB(HueColor + H * 0, svList[i].S, svList[i].V); - main.startColor = new Color(colorHSV.r, colorHSV.g, colorHSV.b, svList[i].A); - i++; - } - } - } - - private ParticleSystem[] particleSystems = new ParticleSystem[0]; - private List svList = new List(); - private float H; - - public struct SVA - { - public float S; - public float V; - public float A; - } - - void Counter(int count) - { - Prefab += count; - if (Prefab > Prefabs.Length - 1) - { - Prefab = 0; - } - else if (Prefab < 0) - { - Prefab = Prefabs.Length - 1; - } - if (Instance != null) - { - Destroy(Instance); - } - Instance = Instantiate(Prefabs[Prefab]); - particleSystems = Instance.GetComponentsInChildren(); //Get color from current instance - svList.Clear(); - foreach (var ps in particleSystems) - { - Color baseColor = ps.main.startColor.color; - SVA baseSVA = new SVA(); - Color.RGBToHSV(baseColor, out H, out baseSVA.S, out baseSVA.V); - baseSVA.A = baseColor.a; - svList.Add(baseSVA); - } - } - - void LateUpdate() - { - if (currDistance < 2) - { - currDistance = 2; - } - currDistance -= Input.GetAxis("Mouse ScrollWheel") * 2; - if (Holder && (Input.GetMouseButton(0) || Input.GetMouseButton(1))) - { - var pos = Input.mousePosition; - float dpiScale = 1; - if (Screen.dpi < 1) dpiScale = 1; - if (Screen.dpi < 200) dpiScale = 1; - else dpiScale = Screen.dpi / 200f; - if (pos.x < 380 * dpiScale && Screen.height - pos.y < 250 * dpiScale) return; - Cursor.visible = false; - Cursor.lockState = CursorLockMode.Locked; - x += (float)(Input.GetAxis("Mouse X") * xRotate * 0.02); - y -= (float)(Input.GetAxis("Mouse Y") * yRotate * 0.02); - y = ClampAngle(y, yMinLimit, yMaxLimit); - var rotation = Quaternion.Euler(y, x, 0); - var position = rotation * new Vector3(0, 0, -currDistance) + Holder.position; - transform.rotation = rotation; - transform.position = position; - } - else - { - Cursor.visible = true; - Cursor.lockState = CursorLockMode.None; - } - - if (prevDistance != currDistance) - { - prevDistance = currDistance; - var rot = Quaternion.Euler(y, x, 0); - var po = rot * new Vector3(0, 0, -currDistance) + Holder.position; - transform.rotation = rot; - transform.position = po; - } - } - - static float ClampAngle(float angle, float min, float max) - { - if (angle < -360) - { - angle += 360; - } - if (angle > 360) - { - angle -= 360; - } - return Mathf.Clamp(angle, min, max); - } -} \ No newline at end of file -- cgit v1.1-26-g67d0