1+ using System . Collections ;
2+ using System . Collections . Generic ;
3+ using UnityEngine ;
4+ using UnityEditor ;
5+
6+ namespace UXFTools
7+ {
8+
9+ [ InitializeOnLoad ]
10+ public class UXFWizard : EditorWindow
11+ {
12+ public Texture2D uxfIcon ;
13+ public static bool forceShow = false ;
14+ ApiCompatibilityLevel targetApiLevel = ApiCompatibilityLevel . NET_2_0 ;
15+ bool updateCompatibilityLevel ;
16+ static string settingsKey = "uxf_seen_wizard" ;
17+
18+ static UXFWizard ( )
19+ {
20+ EditorApplication . projectWindowChanged += OnProjectChanged ;
21+ }
22+
23+
24+ [ MenuItem ( "UXF/Show setup wizard" ) ]
25+ static void Init ( )
26+ {
27+ var window = ( UXFWizard ) EditorWindow . GetWindow ( typeof ( UXFWizard ) , true , "UXF Wizard" ) ;
28+ window . minSize = new Vector2 ( 300 , 501 ) ;
29+ window . titleContent = new GUIContent ( "UXF Wizard" ) ;
30+ window . Show ( ) ;
31+ }
32+
33+ static void OnProjectChanged ( )
34+ {
35+ bool seen ;
36+
37+ if ( EditorPrefs . HasKey ( settingsKey ) )
38+ {
39+ seen = EditorPrefs . GetBool ( settingsKey ) ;
40+ }
41+ else
42+ {
43+ seen = false ;
44+ }
45+
46+ if ( forceShow | ! seen )
47+ {
48+ Init ( ) ;
49+ EditorPrefs . SetBool ( settingsKey , true ) ;
50+ }
51+ }
52+
53+ public void OnGUI ( )
54+ {
55+ GUIStyle labelStyle = new GUIStyle ( ) ;
56+ labelStyle . wordWrap = true ;
57+ labelStyle . margin = new RectOffset ( 6 , 0 , 0 , 0 ) ;
58+
59+ var rect = GUILayoutUtility . GetRect ( Screen . width , 128 , GUI . skin . box ) ;
60+ if ( uxfIcon )
61+ GUI . DrawTexture ( rect , uxfIcon , ScaleMode . ScaleToFit ) ;
62+
63+ GUILayout . BeginHorizontal ( ) ;
64+ GUILayout . FlexibleSpace ( ) ;
65+ GUILayout . Label ( "UXF: Unity Experiment Framework" , EditorStyles . boldLabel ) ;
66+ GUILayout . FlexibleSpace ( ) ;
67+ GUILayout . EndHorizontal ( ) ;
68+
69+ EditorGUILayout . Separator ( ) ;
70+
71+ GUILayout . Label ( "Help and info" , EditorStyles . boldLabel ) ;
72+
73+ GUILayout . Label ( "The GitHub page contains the most up-to-date information & release." , labelStyle ) ;
74+ if ( GUILayout . Button ( "Visit GitHub" ) )
75+ Application . OpenURL ( "https://github.com/jackbrookes/unity-experiment-framework/" ) ;
76+
77+ EditorGUILayout . Space ( ) ;
78+ GUILayout . Label ( "The GitHub Wiki contains documentation and in-depth explanations of concepts." , labelStyle ) ;
79+ if ( GUILayout . Button ( "Visit Wiki" ) )
80+ Application . OpenURL ( "https://github.com/jackbrookes/unity-experiment-framework/wiki" ) ;
81+
82+
83+ EditorGUILayout . Separator ( ) ;
84+
85+ GUILayout . Label ( "Examples" , EditorStyles . boldLabel ) ;
86+
87+ GUILayout . Label ( "Check the /UXF/Examples folder" , labelStyle ) ;
88+
89+ EditorGUILayout . Separator ( ) ;
90+
91+ GUILayout . Label ( "Cite UXF" , EditorStyles . boldLabel ) ;
92+
93+ GUILayout . Label ( "Check back soon!" , labelStyle ) ;
94+
95+ EditorGUILayout . Separator ( ) ;
96+
97+ GUILayout . Label ( "Compatibility" , EditorStyles . boldLabel ) ;
98+
99+ bool compatible = PlayerSettings . GetApiCompatibilityLevel ( BuildTargetGroup . Standalone ) == targetApiLevel ;
100+
101+ if ( compatible )
102+ {
103+ EditorGUILayout . HelpBox ( "API Compatibility Level is set correctly" , MessageType . Info ) ;
104+ }
105+ else
106+ {
107+ EditorGUILayout . HelpBox ( "API Compatibility Level should be set to .NET 2.0, expect errors on building" , MessageType . Warning ) ;
108+ if ( GUILayout . Button ( "Fix" ) )
109+ {
110+ PlayerSettings . SetApiCompatibilityLevel ( BuildTargetGroup . Standalone , targetApiLevel ) ;
111+ }
112+ }
113+
114+ EditorGUILayout . Separator ( ) ;
115+ EditorGUILayout . HelpBox ( "To show this window again go to UXF -> Show setup wizard in the menubar." , MessageType . None ) ;
116+
117+ }
118+
119+ }
120+
121+ }
0 commit comments