forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkedObjectEditor.cs
More file actions
51 lines (47 loc) · 2.38 KB
/
Copy pathNetworkedObjectEditor.cs
File metadata and controls
51 lines (47 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using MLAPI;
using UnityEngine;
namespace UnityEditor
{
[CustomEditor(typeof(NetworkedObject), true)]
[CanEditMultipleObjects]
public class NetworkedObjectEditor : Editor
{
private bool initialized;
private NetworkedObject networkedObject;
private void Init()
{
if (initialized)
return;
initialized = true;
networkedObject = (NetworkedObject)target;
}
public override void OnInspectorGUI()
{
Init();
if (NetworkingManager.singleton == null || (!NetworkingManager.singleton.isServer && !NetworkingManager.singleton.isClient))
base.OnInspectorGUI(); //Only run this if we are NOT running server. This is where the ServerOnly box is drawn
if (!networkedObject.isSpawned && NetworkingManager.singleton != null && NetworkingManager.singleton.isServer)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(new GUIContent("Spawn", "Spawns the object across the network"));
if (GUILayout.Toggle(false, "Spawn", EditorStyles.miniButtonLeft))
{
networkedObject.Spawn();
EditorUtility.SetDirty(target);
}
EditorGUILayout.EndHorizontal();
}
else if(networkedObject.isSpawned)
{
EditorGUILayout.LabelField("NetworkId: ", networkedObject.NetworkId.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("OwnerId: ", networkedObject.OwnerClientId.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("isSpawned: ", networkedObject.isSpawned.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("isLocalPlayer: ", networkedObject.isLocalPlayer.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("isOwner: ", networkedObject.isOwner.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("isOwnedByServer: ", networkedObject.isOwnedByServer.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("isPoolObject: ", networkedObject.isPooledObject.ToString(), EditorStyles.label);
EditorGUILayout.LabelField("isPlayerObject: ", networkedObject.isPlayerObject.ToString(), EditorStyles.label);
}
}
}
}