The Swartz-Manning’s first exhibit will provide a detailed history of Aaron Swartz Day. https://www.aaronswartzday.org/vr
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SteamVR_Editor.cs 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //======= Copyright (c) Valve Corporation, All rights reserved. ===============
  2. //
  3. // Purpose: Custom inspector display for SteamVR_Camera
  4. //
  5. //=============================================================================
  6. using UnityEngine;
  7. using UnityEditor;
  8. using System.IO;
  9. [CustomEditor(typeof(SteamVR_Camera)), CanEditMultipleObjects]
  10. public class SteamVR_Editor : Editor
  11. {
  12. int bannerHeight = 150;
  13. Texture logo;
  14. SerializedProperty script, wireframe;
  15. string GetResourcePath()
  16. {
  17. var ms = MonoScript.FromScriptableObject(this);
  18. var path = AssetDatabase.GetAssetPath(ms);
  19. path = Path.GetDirectoryName(path);
  20. return path.Substring(0, path.Length - "Editor".Length) + "Textures/";
  21. }
  22. void OnEnable()
  23. {
  24. var resourcePath = GetResourcePath();
  25. logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "logo.png");
  26. script = serializedObject.FindProperty("m_Script");
  27. wireframe = serializedObject.FindProperty("wireframe");
  28. foreach (SteamVR_Camera target in targets)
  29. target.ForceLast();
  30. }
  31. public override void OnInspectorGUI()
  32. {
  33. serializedObject.Update();
  34. var rect = GUILayoutUtility.GetRect(Screen.width - 38, bannerHeight, GUI.skin.box);
  35. if (logo)
  36. GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
  37. if (!Application.isPlaying)
  38. {
  39. var expand = false;
  40. var collapse = false;
  41. foreach (SteamVR_Camera target in targets)
  42. {
  43. if (AssetDatabase.Contains(target))
  44. continue;
  45. if (target.isExpanded)
  46. collapse = true;
  47. else
  48. expand = true;
  49. }
  50. if (expand)
  51. {
  52. GUILayout.BeginHorizontal();
  53. if (GUILayout.Button("Expand"))
  54. {
  55. foreach (SteamVR_Camera target in targets)
  56. {
  57. if (AssetDatabase.Contains(target))
  58. continue;
  59. if (!target.isExpanded)
  60. {
  61. target.Expand();
  62. EditorUtility.SetDirty(target);
  63. }
  64. }
  65. }
  66. GUILayout.Space(18);
  67. GUILayout.EndHorizontal();
  68. }
  69. if (collapse)
  70. {
  71. GUILayout.BeginHorizontal();
  72. if (GUILayout.Button("Collapse"))
  73. {
  74. foreach (SteamVR_Camera target in targets)
  75. {
  76. if (AssetDatabase.Contains(target))
  77. continue;
  78. if (target.isExpanded)
  79. {
  80. target.Collapse();
  81. EditorUtility.SetDirty(target);
  82. }
  83. }
  84. }
  85. GUILayout.Space(18);
  86. GUILayout.EndHorizontal();
  87. }
  88. }
  89. EditorGUILayout.PropertyField(script);
  90. EditorGUILayout.PropertyField(wireframe);
  91. serializedObject.ApplyModifiedProperties();
  92. }
  93. public static void ExportPackage()
  94. {
  95. AssetDatabase.ExportPackage(new string[] {
  96. "Assets/SteamVR",
  97. "Assets/Plugins/openvr_api.cs",
  98. "Assets/Plugins/openvr_api.bundle",
  99. "Assets/Plugins/x86/openvr_api.dll",
  100. "Assets/Plugins/x86/steam_api.dll",
  101. "Assets/Plugins/x86/libsteam_api.so",
  102. "Assets/Plugins/x86_64/openvr_api.dll",
  103. "Assets/Plugins/x86_64/steam_api.dll",
  104. "Assets/Plugins/x86_64/libsteam_api.so",
  105. "Assets/Plugins/x86_64/libopenvr_api.so",
  106. }, "steamvr.unitypackage", ExportPackageOptions.Recurse);
  107. EditorApplication.Exit(0);
  108. }
  109. }