//TODO: check if this can be internal protected (as source in editor AND as dll) public static void LoadAllScenesToFix() { string[] scenes = System.IO.Directory.GetFiles(".", "*.unity", SearchOption.AllDirectories); foreach (string scene in scenes) { EditorSceneManager.OpenScene(scene); PhotonViewHandler.HierarchyChange(); //NOTE: most likely on load also triggers a hierarchy change EditorSceneManager.SaveOpenScenes(); } Debug.Log("Corrected scene views where needed."); }
public override void OnInspectorGUI() { this.m_Target = (PhotonView)this.target; bool isProjectPrefab = PhotonEditorUtils.IsPrefab(this.m_Target.gameObject); if (this.m_Target.ObservedComponents == null) { this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>(); } if (this.m_Target.ObservedComponents.Count == 0) { this.m_Target.ObservedComponents.Add(null); } EditorGUILayout.BeginHorizontal(); // Owner if (isProjectPrefab) { EditorGUILayout.LabelField("Owner:", "Set at runtime"); } else if (!this.m_Target.IsOwnerActive) { EditorGUILayout.LabelField("Owner", "Scene"); } else { Player owner = this.m_Target.Owner; string ownerInfo = (owner != null) ? owner.NickName : "<no Player found>"; if (string.IsNullOrEmpty(ownerInfo)) { ownerInfo = "<no playername set>"; } EditorGUILayout.LabelField("Owner", "[" + this.m_Target.OwnerActorNr + "] " + ownerInfo); } // ownership requests EditorGUI.BeginDisabledGroup(Application.isPlaying); OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(this.m_Target.OwnershipTransfer, GUILayout.Width(100)); if (own != this.m_Target.OwnershipTransfer) { // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change. // not touching the define nor the rest of the code to avoid bringing more problem than solving. EditorUtility.SetDirty(this.m_Target); Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer"); this.m_Target.OwnershipTransfer = own; } EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); // View ID if (isProjectPrefab) { EditorGUILayout.LabelField("View ID", "Set at runtime"); } else if (EditorApplication.isPlaying) { EditorGUILayout.LabelField("View ID", this.m_Target.ViewID.ToString()); } else { int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", this.m_Target.ViewID); if (this.m_Target.ViewID != idValue) { Undo.RecordObject(this.m_Target, "Change PhotonView viewID"); this.m_Target.ViewID = idValue; } } // Locally Controlled if (EditorApplication.isPlaying) { string masterClientHint = PhotonNetwork.IsMasterClient ? "(master)" : ""; EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, this.m_Target.IsMine); } // ViewSynchronization (reliability) if (this.m_Target.Synchronization == ViewSynchronization.Off) { GUI.color = Color.grey; } EditorGUILayout.PropertyField(this.serializedObject.FindProperty("Synchronization"), new GUIContent("Observe option:")); if (this.m_Target.Synchronization != ViewSynchronization.Off && this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0) { GUILayout.BeginVertical(GUI.skin.box); GUILayout.Label("Warning", EditorStyles.boldLabel); GUILayout.Label("Setting the synchronization option only makes sense if you observe something."); GUILayout.EndVertical(); } GUI.color = Color.white; this.DrawObservedComponentsList(); // Cleanup: save and fix look if (GUI.changed) { PhotonViewHandler.HierarchyChange(); // TODO: check if needed } GUI.color = Color.white; }