PresetViewer.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /// ProFlares - v1.08 - Copyright 2014-2015 All rights reserved - ProFlares.com
  2. using UnityEngine;
  3. using System.Collections;
  4. public class PresetViewer : MonoBehaviour {
  5. public Transform PresetParent;
  6. public Camera MainCamera;
  7. public Texture2D Logo;
  8. public Texture2D Info;
  9. public Texture2D Black;
  10. int currentFlare = 0;
  11. public GameObject[] Flares;
  12. void Start () {
  13. //return;
  14. for(int i = 0; i < Flares.Length;i++){
  15. Flares[i].SetActive(false);
  16. }
  17. Flares[currentFlare].SetActive(true);
  18. }
  19. // Update is called once per frame
  20. void Update () {
  21. if(Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow)){
  22. for(int i = 0; i < Flares.Length;i++){
  23. Flares[i].SetActive(false);
  24. }
  25. if(Input.GetKeyUp(KeyCode.LeftArrow))
  26. currentFlare--;
  27. else
  28. currentFlare++;
  29. if(currentFlare < 0) currentFlare = Flares.Length-1;
  30. if(currentFlare > Flares.Length-1) currentFlare = 0;
  31. Flares[currentFlare].SetActive(true);
  32. }
  33. //if(!hideGui)
  34. if(Input.GetMouseButton(0)){
  35. float extra = 1.2f;
  36. Ray ray = MainCamera.ScreenPointToRay(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
  37. Debug.DrawRay(ray.origin, ray.direction * 10, Color.yellow);
  38. RaycastHit hit;
  39. if(Physics.Raycast(ray,out hit)){
  40. PresetParent.position = hit.point*extra;
  41. }
  42. }
  43. }
  44. public bool hideGui = false;
  45. void OnGUI(){
  46. if(hideGui)
  47. return;
  48. GUIStyle LogoStyle = new GUIStyle();
  49. LogoStyle.active.background = Logo;
  50. LogoStyle.normal.background = Logo;
  51. LogoStyle.richText = true;
  52. LogoStyle.alignment = TextAnchor.MiddleCenter;
  53. LogoStyle.normal.textColor = Color.white;
  54. GUIStyle styleInfo = new GUIStyle();
  55. styleInfo.active.background = Info;
  56. styleInfo.normal.background = Info;
  57. styleInfo.richText = true;
  58. styleInfo.alignment = TextAnchor.MiddleCenter;
  59. styleInfo.normal.textColor = Color.white;
  60. if(GUI.Button(new Rect(10,0,Logo.width,Logo.height),"",LogoStyle)){
  61. Application.OpenURL("http://proflares.com/store");
  62. }
  63. if(GUI.Button(new Rect((MainCamera.pixelRect.width*0.5f)-(Info.width*0.5f),MainCamera.pixelRect.height-Info.height,Info.width,Info.height),"",styleInfo)){}
  64. }
  65. void drawTexture(float x, float y, Texture2D texture) {
  66. if(texture != null){
  67. Rect texRect = new Rect(x,y,texture.width,texture.height);
  68. GUI.color = Color.white;
  69. GUI.DrawTexture(texRect, texture);
  70. }
  71. }
  72. }