Skip to content

Commit 9e2e2a3

Browse files
committed
Removed unused files and fixed compilation for solution
1 parent 94bb07c commit 9e2e2a3

File tree

16 files changed

+93
-429
lines changed

16 files changed

+93
-429
lines changed

MLAPI-Editor/MLAPIProfiler.cs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,38 @@ GUIStyle wrapStyle
3737
class ProfilerContainer
3838
{
3939
public ProfilerTick[] ticks;
40-
}
4140

42-
private void StopRecording()
41+
public byte[] ToBytes()
42+
{
43+
MLAPI.NetworkingManagerComponents.Binary.BitStream stream = new MLAPI.NetworkingManagerComponents.Binary.BitStream();
44+
BitWriter writer = new BitWriter(stream);
45+
writer.WriteUInt16Packed((ushort)ticks.Length);
46+
47+
for (int i = 0; i < ticks.Length; i++)
48+
{
49+
ticks[i].SerializeToStream(stream);
50+
}
51+
52+
return stream.ToArray();
53+
}
54+
55+
public static ProfilerContainer FromBytes(byte[] bytes)
56+
{
57+
ProfilerContainer container = new ProfilerContainer();
58+
MLAPI.NetworkingManagerComponents.Binary.BitStream stream = new MLAPI.NetworkingManagerComponents.Binary.BitStream(bytes);
59+
BitReader reader = new BitReader(stream);
60+
ushort count = reader.ReadUInt16Packed();
61+
container.ticks = new ProfilerTick[count];
62+
for (int i = 0; i < count; i++)
63+
{
64+
container.ticks[i] = ProfilerTick.FromStream(stream);
65+
}
66+
67+
return container;
68+
}
69+
}
70+
71+
private void StopRecording()
4372
{
4473
NetworkProfiler.Stop();
4574
}
@@ -94,7 +123,7 @@ private void OnGUI()
94123
string path = EditorUtility.OpenFilePanel("Choose a NetworkProfiler file", "", "");
95124
if (!string.IsNullOrEmpty(path))
96125
{
97-
ProfilerTick[] ticks = BinarySerializer.Deserialize<ProfilerContainer>(File.ReadAllBytes(path)).ticks;
126+
ProfilerTick[] ticks = ProfilerContainer.FromBytes(File.ReadAllBytes(path)).ticks;
98127
if (ticks.Length >= 2)
99128
{
100129
curve = AnimationCurve.Constant(ticks[0].EventId, ticks[(ticks.Length - 1)].EventId, 0);
@@ -130,7 +159,7 @@ private void OnGUI()
130159
ProfilerTick[] ticks = new ProfilerTick[ticksInRange];
131160
for (int i = min; i < max; i++) ticks[i - min] = currentTicks[i];
132161
string path = EditorUtility.SaveFilePanel("Save NetworkProfiler data", "", "networkProfilerData", "");
133-
if (!string.IsNullOrEmpty(path)) File.WriteAllBytes(path, BinarySerializer.Serialize(new ProfilerContainer() { ticks = ticks }));
162+
if (!string.IsNullOrEmpty(path)) File.WriteAllBytes(path, new ProfilerContainer() { ticks = ticks }.ToBytes());
134163
}
135164

136165
EditorGUILayout.EndHorizontal();

MLAPI-Editor/NetworkedBehaviourEditor.cs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using MLAPI.Attributes;
2-
using MLAPI.Data;
1+
using MLAPI.Data;
32
using MLAPI.MonoBehaviours.Core;
43
using System;
54
using System.Collections.Generic;
@@ -13,33 +12,25 @@ namespace UnityEditor
1312
public class NetworkedBehaviourEditor : Editor
1413
{
1514
private bool initialized;
16-
private HashSet<string> syncedVarNames = new HashSet<string>();
1715
private List<string> networkedVarNames = new List<string>();
1816
private Dictionary<string, FieldInfo> networkedVarFields = new Dictionary<string, FieldInfo>();
1917
private Dictionary<string, object> networkedVarObjects = new Dictionary<string, object>();
20-
21-
private GUIContent syncedVarLabelGuiContent;
18+
2219
private GUIContent networkedVarLabelGuiContent;
2320

2421
private void Init(MonoScript script)
2522
{
2623
initialized = true;
27-
28-
syncedVarNames.Clear();
24+
2925
networkedVarNames.Clear();
3026
networkedVarFields.Clear();
3127
networkedVarObjects.Clear();
3228

33-
syncedVarLabelGuiContent = new GUIContent("SyncedVar", "This variable has been marked with the [SyncedVar] attribute.");
3429
networkedVarLabelGuiContent = new GUIContent("NetworkedVar", "This variable is a NetworkedVar. It can not be serialized and can only be changed during runtime.");
3530

3631
FieldInfo[] fields = script.GetClass().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy | BindingFlags.NonPublic);
3732
for (int i = 0; i < fields.Length; i++)
3833
{
39-
Attribute[] attributes = (Attribute[])fields[i].GetCustomAttributes(typeof(SyncedVar), true);
40-
if (attributes.Length > 0)
41-
syncedVarNames.Add(fields[i].Name);
42-
4334
Type ft = fields[i].FieldType;
4435
if (ft.IsGenericType && ft.GetGenericTypeDefinition() == typeof(NetworkedVar<>))
4536
{
@@ -139,28 +130,20 @@ public override void OnInspectorGUI()
139130
bool expanded = true;
140131
while (property.NextVisible(expanded))
141132
{
142-
bool isSyncVar = syncedVarNames.Contains(property.name);
143133
if (property.propertyType == SerializedPropertyType.ObjectReference)
144134
{
145135
if (property.name == "m_Script")
146136
EditorGUI.BeginDisabledGroup(true);
147137

148138
EditorGUILayout.PropertyField(property, true);
149-
150-
if (isSyncVar)
151-
GUILayout.Label(syncedVarLabelGuiContent, EditorStyles.miniLabel, GUILayout.Width(EditorStyles.miniLabel.CalcSize(syncedVarLabelGuiContent).x));
152-
139+
153140
if (property.name == "m_Script")
154141
EditorGUI.EndDisabledGroup();
155142
}
156143
else
157144
{
158145
EditorGUILayout.BeginHorizontal();
159146
EditorGUILayout.PropertyField(property, true);
160-
161-
if (isSyncVar)
162-
GUILayout.Label(syncedVarLabelGuiContent, EditorStyles.miniLabel, GUILayout.Width(EditorStyles.miniLabel.CalcSize(syncedVarLabelGuiContent).x));
163-
164147
EditorGUILayout.EndHorizontal();
165148
}
166149
expanded = false;

MLAPI-Editor/NetworkedObjectEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public override void OnInspectorGUI()
4343
EditorGUILayout.LabelField("isSpawned: ", networkedObject.isSpawned.ToString(), EditorStyles.label);
4444
EditorGUILayout.LabelField("isLocalPlayer: ", networkedObject.isLocalPlayer.ToString(), EditorStyles.label);
4545
EditorGUILayout.LabelField("isOwner: ", networkedObject.isOwner.ToString(), EditorStyles.label);
46-
EditorGUILayout.LabelField("isObjectOwner: ", networkedObject.isObjectOwner.ToString(), EditorStyles.label);
46+
EditorGUILayout.LabelField("isOwnedByServer: ", networkedObject.isOwnedByServer.ToString(), EditorStyles.label);
4747
EditorGUILayout.LabelField("isPoolObject: ", networkedObject.isPooledObject.ToString(), EditorStyles.label);
4848
EditorGUILayout.LabelField("isPlayerObject: ", networkedObject.isPlayerObject.ToString(), EditorStyles.label);
4949
}

MLAPI.Tests/Data/FieldTypeTests.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

MLAPI.Tests/MLAPI.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636
</Reference>
3737
</ItemGroup>
3838
<ItemGroup>
39-
<Compile Include="Data\FieldTypeTests.cs" />
4039
<Compile Include="Test.cs" />
41-
<Compile Include="NetworkingManagerComponents\Binary\BitWriterTest.cs" />
4240
<Compile Include="Data\HashCodeTest.cs" />
4341
<Compile Include="NetworkingManagerComponents\Binary\ArithmeticTest.cs" />
4442
<Compile Include="NetworkingManagerComponents\Binary\BitStreamTest.cs" />

MLAPI.Tests/NetworkingManagerComponents/Binary/BitWriterTest.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

MLAPI/Attributes/BinaryIgnore.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

MLAPI/Attributes/ClientRpc.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

MLAPI/Attributes/Command.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

MLAPI/Attributes/SyncedVar.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)