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