private void Reset() { #if UNITY_EDITOR RealtimeViewConfiguration._ConfigureRealtimeView(this); #endif }
public override void OnInspectorGUI() { GUILayout.Space(12); // Properties Start GUI.enabled = !Application.isPlaying; serializedObject.Update(); // Scene View bool isRootSceneView = realtimeView.isRootSceneView; byte[] sceneViewUUID = RealtimeViewConfiguration.GetSceneViewUUIDAsByteArray(sceneViewUUIDProperty); if (isRootSceneView) { // UUID string sceneViewUUIDString = ""; if (sceneViewUUID.Length == 16) { sceneViewUUIDString = new Guid(sceneViewUUID).ToString(); } else { StringBuilder sceneViewUUIDHexString = new StringBuilder(sceneViewUUID.Length * 2); foreach (byte value in sceneViewUUID) { sceneViewUUIDHexString.AppendFormat("{0:x2}", value); } sceneViewUUIDString = sceneViewUUIDHexString.ToString(); } GUILayout.Label("Scene View UUID: " + sceneViewUUIDString); GUILayout.Space(4); } // Components _components.DoLayoutList(); GUILayout.Space(4); // Child Views _childViews.DoLayoutList(); // Right now all advanced settings are scene view specific. If that changes, remove this if statement. if (isRootSceneView) { // Advanced Settings GUIStyle foldoutStyle = EditorStyles.foldout; FontStyle previousFoldoutFontStyle = foldoutStyle.fontStyle; //foldoutStyle.fontStyle = FontStyle.Bold; __showAdvancedSettings = EditorGUILayout.Foldout(__showAdvancedSettings, "Advanced Settings", foldoutStyle); foldoutStyle.fontStyle = previousFoldoutFontStyle; EditorPrefs.SetBool("Normal.RealtimeViewEditor.ShowAdvancedSettings", __showAdvancedSettings); if (__showAdvancedSettings) { if (isRootSceneView) { // Realtime realtimeProperty.objectReferenceValue = EditorGUILayout.ObjectField("Realtime Instance", realtimeProperty.objectReferenceValue, typeof(Realtime), true); // Ownership & lifetime sceneViewOwnedByCreatingClientDProperty.boolValue = EditorGUILayout.ToggleLeft("Owned By Creating Client", sceneViewOwnedByCreatingClientDProperty.boolValue); sceneViewPreventOwnershipTakeoverProperty.boolValue = EditorGUILayout.ToggleLeft("Prevent Ownership Takeover", sceneViewPreventOwnershipTakeoverProperty.boolValue); sceneViewDestroyWhenOwnerOrLastClientLeavesProperty.boolValue = EditorGUILayout.ToggleLeft("Destroy When Owner Or Last Client Leaves", sceneViewDestroyWhenOwnerOrLastClientLeavesProperty.boolValue); // Reset UUID if (GUILayout.Button("Reset View UUID")) { if (EditorUtility.DisplayDialog("Reset RealtimeView UUID", "YO!!! This is a dangerous operation! Be careful!\n\nThis RealtimeView will no longer be able to retrieve persistent state that was stored under the previous UUID.\n\nAre you sure you want to reset it?", "OK", "Cancel")) { sceneViewUUID = RealtimeViewConfiguration.SetSceneViewUUIDUsingByteArray(sceneViewUUIDProperty, Guid.NewGuid().ToByteArray()); // Update the map RealtimeViewConfiguration._UpdateRealtimeViewSceneViewUUID(realtimeView, sceneViewUUID); } } } GUILayout.Space(2); } } // Properties End serializedObject.ApplyModifiedProperties(); GUILayout.Space(2); // Ownership GUI.enabled = isOnline; GUILayout.Label("Owner: " + GetOwner()); GUILayout.BeginHorizontal(); if (GUILayout.Button("Request Ownership")) { RequestOwnership(); } if (GUILayout.Button("Clear Ownership")) { ClearOwnership(); } GUILayout.EndHorizontal(); GUILayout.Space(4); // Reset GUI.enabled = true; }