remove NetworkIdentityEditor because it's not really needed after removing local player authority (which required special checks to only show one option at a time). Also fixes #1289 (#1309)

This commit is contained in:
vis2k 2019-12-16 08:50:47 +01:00 committed by GitHub
parent 3b1e6dcc6f
commit 6fb8a32f5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 94 deletions

View File

@ -1,81 +0,0 @@
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace Mirror
{
[CustomEditor(typeof(NetworkIdentity), true)]
[CanEditMultipleObjects]
public class NetworkIdentityEditor : Editor
{
SerializedProperty serverOnlyProperty;
readonly GUIContent serverOnlyLabel = new GUIContent("Server Only", "True if the object should only exist on the server.");
readonly GUIContent spawnLabel = new GUIContent("Spawn Object", "This causes an unspawned server object to be spawned on clients");
NetworkIdentity networkIdentity;
bool showObservers;
void Init()
{
if (serverOnlyProperty == null)
{
networkIdentity = target as NetworkIdentity;
serverOnlyProperty = serializedObject.FindProperty("serverOnly");
}
}
public override void OnInspectorGUI()
{
Init();
serializedObject.Update();
EditorGUILayout.PropertyField(serverOnlyProperty, serverOnlyLabel);
serializedObject.ApplyModifiedProperties();
if (!Application.isPlaying)
{
return;
}
// Runtime actions below here
EditorGUILayout.Separator();
if (networkIdentity.observers != null && networkIdentity.observers.Count > 0)
{
showObservers = EditorGUILayout.Foldout(showObservers, "Observers");
if (showObservers)
{
EditorGUI.indentLevel += 1;
foreach (KeyValuePair<int, NetworkConnection> kvp in networkIdentity.observers)
{
if (kvp.Value.identity != null)
EditorGUILayout.ObjectField(kvp.Value.ToString(), kvp.Value.identity.gameObject, typeof(GameObject), false);
else
EditorGUILayout.TextField(kvp.Value.ToString());
}
EditorGUI.indentLevel -= 1;
}
}
if (PrefabUtility.IsPartOfPrefabAsset(networkIdentity.gameObject))
return;
if (networkIdentity.gameObject.activeSelf && networkIdentity.netId == 0 && NetworkServer.active)
{
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(spawnLabel);
if (GUILayout.Toggle(false, "Spawn", EditorStyles.miniButtonLeft))
{
NetworkServer.Spawn(networkIdentity.gameObject);
EditorUtility.SetDirty(target); // preview window STILL doens't update immediately..
}
EditorGUILayout.EndHorizontal();
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 1b6e3680cc14b4769bff378e5dbc3544
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -125,7 +125,7 @@ public sealed class NetworkIdentity : MonoBehaviour
public NetworkBehaviour[] NetworkBehaviours => networkBehavioursCache = networkBehavioursCache ?? GetComponents<NetworkBehaviour>();
[SerializeField] string m_AssetId;
[SerializeField, HideInInspector] string m_AssetId;
// the AssetId trick:
// - ideally we would have a serialized 'Guid m_AssetId' but Unity can't
@ -168,7 +168,7 @@ internal set
// suppress "Field 'NetworkIdentity.m_SceneId' is never assigned to, and will always have its default value 0"
// when building standalone
#pragma warning disable CS0649
[SerializeField] ulong m_SceneId;
[SerializeField, HideInInspector] ulong m_SceneId;
#pragma warning restore CS0649
// keep track of all sceneIds to detect scene duplicates