multiple xr toolkit package
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.

VRCSdkControlPanel.cs 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. using UnityEditor;
  2. using UnityEngine;
  3. using VRC.Core;
  4. [ExecuteInEditMode]
  5. public partial class VRCSdkControlPanel : EditorWindow
  6. {
  7. public static VRCSdkControlPanel window;
  8. [MenuItem("VRChat SDK/Show Control Panel", false, 600)]
  9. static void ShowControlPanel()
  10. {
  11. if (!RemoteConfig.IsInitialized())
  12. {
  13. VRC.Core.API.SetOnlineMode(true, "vrchat");
  14. RemoteConfig.Init(() => ShowControlPanel());
  15. return;
  16. }
  17. window = (VRCSdkControlPanel)EditorWindow.GetWindow(typeof(VRCSdkControlPanel));
  18. window.titleContent.text = "VRChat SDK";
  19. window.minSize = new Vector2(SdkWindowWidth + 4, 600);
  20. window.maxSize = new Vector2(SdkWindowWidth + 4, 2000);
  21. window.Init();
  22. window.Show();
  23. }
  24. void Update()
  25. {
  26. Repaint();
  27. }
  28. static GUIStyle titleGuiStyle;
  29. static GUIStyle boxGuiStyle;
  30. static GUIStyle infoGuiStyle;
  31. static GUIStyle listButtonStyleEven;
  32. static GUIStyle listButtonStyleOdd;
  33. static GUIStyle listButtonStyleSelected;
  34. void InitializeStyles()
  35. {
  36. titleGuiStyle = new GUIStyle();
  37. titleGuiStyle.fontSize = 15;
  38. titleGuiStyle.fontStyle = FontStyle.BoldAndItalic;
  39. titleGuiStyle.alignment = TextAnchor.MiddleCenter;
  40. titleGuiStyle.wordWrap = true;
  41. if (EditorGUIUtility.isProSkin)
  42. titleGuiStyle.normal.textColor = Color.white;
  43. else
  44. titleGuiStyle.normal.textColor = Color.black;
  45. boxGuiStyle = new GUIStyle();
  46. if (EditorGUIUtility.isProSkin)
  47. {
  48. boxGuiStyle.normal.background = CreateBackgroundColorImage(new Color(0.6f, 0.6f, 0.6f));
  49. boxGuiStyle.normal.textColor = Color.white;
  50. }
  51. else
  52. {
  53. boxGuiStyle.normal.background = CreateBackgroundColorImage(new Color(0.85f, 0.85f, 0.85f));
  54. boxGuiStyle.normal.textColor = Color.black;
  55. }
  56. infoGuiStyle = new GUIStyle();
  57. infoGuiStyle.wordWrap = true; ;
  58. if (EditorGUIUtility.isProSkin)
  59. infoGuiStyle.normal.textColor = Color.white;
  60. else
  61. infoGuiStyle.normal.textColor = Color.black;
  62. infoGuiStyle.margin = new RectOffset(10, 10, 10, 10);
  63. listButtonStyleEven = new GUIStyle();
  64. listButtonStyleEven.margin = new RectOffset(0, 0, 0, 0);
  65. listButtonStyleEven.border = new RectOffset(0, 0, 0, 0);
  66. if (EditorGUIUtility.isProSkin)
  67. {
  68. listButtonStyleEven.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
  69. listButtonStyleEven.normal.background = CreateBackgroundColorImage(new Color(0.540f, 0.540f, 0.54f));
  70. }
  71. else
  72. {
  73. listButtonStyleEven.normal.textColor = Color.black;
  74. listButtonStyleEven.normal.background = CreateBackgroundColorImage(new Color(0.85f, 0.85f, 0.85f));
  75. }
  76. listButtonStyleOdd = new GUIStyle();
  77. listButtonStyleOdd.margin = new RectOffset(0, 0, 0, 0);
  78. listButtonStyleOdd.border = new RectOffset(0, 0, 0, 0);
  79. if (EditorGUIUtility.isProSkin)
  80. {
  81. listButtonStyleOdd.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
  82. //listButtonStyleOdd.normal.background = CreateBackgroundColorImage(new Color(0.50f, 0.50f, 0.50f));
  83. }
  84. else
  85. {
  86. listButtonStyleOdd.normal.textColor = Color.black;
  87. listButtonStyleOdd.normal.background = CreateBackgroundColorImage(new Color(0.90f, 0.90f, 0.90f));
  88. }
  89. listButtonStyleSelected = new GUIStyle();
  90. listButtonStyleSelected.normal.textColor = Color.white;
  91. listButtonStyleSelected.margin = new RectOffset(0, 0, 0, 0);
  92. if (EditorGUIUtility.isProSkin)
  93. {
  94. listButtonStyleSelected.normal.textColor = new Color(0.8f, 0.8f, 0.8f);
  95. listButtonStyleSelected.normal.background = CreateBackgroundColorImage(new Color(0.4f, 0.4f, 0.4f));
  96. }
  97. else
  98. {
  99. listButtonStyleSelected.normal.textColor = Color.black;
  100. listButtonStyleSelected.normal.background = CreateBackgroundColorImage(new Color(0.75f, 0.75f, 0.75f));
  101. }
  102. }
  103. void Init()
  104. {
  105. InitializeStyles();
  106. ResetIssues();
  107. InitAccount();
  108. }
  109. void OnEnable()
  110. {
  111. OnEnableAccount();
  112. AssemblyReloadEvents.afterAssemblyReload += BuilderAssemblyReload;
  113. }
  114. void OnDisable()
  115. {
  116. AssemblyReloadEvents.afterAssemblyReload -= BuilderAssemblyReload;
  117. }
  118. void OnDestroy()
  119. {
  120. AccountDestroy();
  121. }
  122. const int SdkWindowWidth = 518;
  123. void OnGUI()
  124. {
  125. if (window == null)
  126. {
  127. window = (VRCSdkControlPanel)EditorWindow.GetWindow(typeof(VRCSdkControlPanel));
  128. InitializeStyles();
  129. }
  130. if (_bannerImage == null)
  131. _bannerImage = AssetDatabase.LoadAssetAtPath("Assets/VRCSDK/Dependencies/VRChat/SdkGraphics/SDK_Panel_Banner.png", typeof(Texture2D)) as Texture2D;
  132. GUILayout.Box(_bannerImage);
  133. if (Application.isPlaying)
  134. {
  135. EditorGUILayout.LabelField("You cannot edit your VRChat data while the Unity Application is running");
  136. return;
  137. }
  138. EditorGUILayout.Space();
  139. VRCSettings.Get().activeWindowPanel = GUILayout.Toolbar(VRCSettings.Get().activeWindowPanel, new string[] { "Authentication", "Builder", "Content Manager", "Settings" }, GUILayout.Width(SdkWindowWidth));
  140. int showPanel = VRCSettings.Get().activeWindowPanel;
  141. if (APIUser.IsLoggedInWithCredentials == false && showPanel != 3)
  142. showPanel = 0;
  143. switch (showPanel)
  144. {
  145. case 1:
  146. ShowBuilder();
  147. break;
  148. case 2:
  149. ShowContent();
  150. break;
  151. case 3:
  152. ShowSettings();
  153. break;
  154. case 0:
  155. default:
  156. ShowAccount();
  157. break;
  158. }
  159. }
  160. [UnityEditor.Callbacks.PostProcessScene]
  161. static void OnPostProcessScene()
  162. {
  163. if (window != null)
  164. window.Reset();
  165. }
  166. private void OnFocus()
  167. {
  168. Reset();
  169. }
  170. public void Reset()
  171. {
  172. ResetIssues();
  173. }
  174. [UnityEditor.Callbacks.DidReloadScripts(int.MaxValue)]
  175. static void DidReloadScripts()
  176. {
  177. RefreshApiUrlSetting();
  178. }
  179. }