public override void OnInspectorGUI() { EditorGUILayout.LabelField("LAN IP", TNet.Tools.localAddress.ToString()); EditorGUILayout.LabelField("WAN IP", TNet.Tools.externalAddress.ToString()); EditorGUILayout.LabelField("Player Name", TNManager.playerName); if (TNManager.isConnected) { EditorGUILayout.LabelField("Ping", TNManager.ping.ToString()); List <Channel> list = TNManager.channels; foreach (Channel ch in list) { GUILayout.Space(6f); EditorGUILayout.LabelField("Channel #" + ch.id, TNManager.GetHost(ch.id).name); EditorGUILayout.LabelField("Players", (TNManager.GetPlayers(ch.id).size + 1).ToString()); EditorGUILayout.LabelField("Host", (TNManager.GetHost(ch.id).name).ToString()); } } serializedObject.Update(); if (Application.isPlaying) { EditorGUI.BeginDisabledGroup(true); serializedObject.DrawProperty("objects", "Referenced Objects"); EditorGUI.EndDisabledGroup(); } else { serializedObject.DrawProperty("objects", "Referenced Objects"); } serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Automatically transfer the ownership. The same action happens on the server. /// </summary> void OnPlayerLeave(int channelID, Player p) { if (channelID == this.channelID && p != null && mOwner == p) { mOwner = TNManager.GetHost(channelID); } }
public override void OnInspectorGUI() { TNObject obj = target as TNObject; if (Application.isPlaying) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Channel", obj.channelID.ToString("N0")); EditorGUILayout.LabelField("ID", obj.uid.ToString("N0")); EditorGUILayout.LabelField("Creator", obj.creatorPlayerID.ToString("N0")); if (obj.owner != null) { EditorGUILayout.LabelField("Owner", obj.owner.name + " (" + obj.ownerID.ToString("N0") + ")"); } else { EditorGUILayout.LabelField("Owner", obj.ownerID.ToString("N0")); } var host = TNManager.GetHost(obj.channelID); EditorGUILayout.LabelField("Host", (host != null) ? host.name : "<none>"); if (obj.parent != null) { EditorGUILayout.ObjectField("Parent", obj.parent, typeof(TNObject), true); } var data = obj.dataNode; if (data != null && data.children.size > 0) { Print(data); } EditorGUI.EndDisabledGroup(); } else { serializedObject.Update(); var staticID = serializedObject.FindProperty("mStaticID"); EditorGUILayout.PropertyField(staticID, new GUIContent("ID")); var sp = serializedObject.FindProperty("ignoreWarnings"); EditorGUILayout.PropertyField(sp, new GUIContent("Ignore Warnings")); var type = PrefabUtility.GetPrefabType(obj.gameObject); if (type == PrefabType.Prefab) { serializedObject.ApplyModifiedProperties(); return; } if (staticID.intValue == 0) { EditorGUILayout.HelpBox("Object ID of '0' means this object must be dynamically instantiated via TNManager.Instantiate.", MessageType.Info); if (GUILayout.Button("Assign Unique ID")) { staticID.intValue = (int)TNObject.GetUniqueID(false); } } else { var tnos = FindObjectsOfType <TNObject>(); foreach (TNObject o in tnos) { if (o == obj || o.parent != null) { continue; } if (o.uid == obj.uid) { EditorGUILayout.HelpBox("This ID is shared with other TNObjects. A unique ID is required in order for RFCs to function properly.", MessageType.Error); break; } } } serializedObject.ApplyModifiedProperties(); } }
public override void OnInspectorGUI() { TNObject obj = target as TNObject; if (Application.isPlaying) { EditorGUI.BeginDisabledGroup(true); EditorGUILayout.LabelField("Channel", obj.channelID.ToString()); EditorGUILayout.LabelField("ID", obj.uid.ToString()); if (obj.owner != null) { EditorGUILayout.LabelField("Owner", obj.owner.name + " (" + obj.ownerID + ")"); } else { EditorGUILayout.LabelField("Owner", obj.ownerID.ToString()); } TNet.Player host = TNManager.GetHost(TNManager.lastChannelID); EditorGUILayout.LabelField("Host", (host != null) ? host.name : "<none>"); if (obj.parent != null) { EditorGUILayout.ObjectField("Parent", obj.parent, typeof(TNObject), true); } EditorGUI.EndDisabledGroup(); } else { serializedObject.Update(); SerializedProperty sp = serializedObject.FindProperty("id"); EditorGUILayout.PropertyField(sp, new GUIContent("ID")); serializedObject.ApplyModifiedProperties(); PrefabType type = PrefabUtility.GetPrefabType(obj.gameObject); if (type == PrefabType.Prefab) { return; } if (obj.uid == 0) { EditorGUILayout.HelpBox("Object ID of '0' means this object must be dynamically instantiated via TNManager.Instantiate.", MessageType.Info); } else { TNObject[] tnos = FindObjectsOfType <TNObject>(); foreach (TNObject o in tnos) { if (o == obj || o.parent != null) { continue; } if (o.uid == obj.uid) { EditorGUILayout.HelpBox("This ID is shared with other TNObjects. A unique ID is required in order for RFCs to function properly.", MessageType.Error); break; } } } } }