Skip to content

Commit 86db3c5

Browse files
committed
fix: fixed mirage define and fixed for new mirage version where james implemented nullable for position in spawn message.
1 parent 08cb0da commit 86db3c5

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

Assets/Object Pooler/Object Pooler.asmdef

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"versionDefines": [
1616
{
1717
"name": "com.miragenet.mirage",
18-
"expression": "",
18+
"expression": "100.0.0",
1919
"define": "MIRAGE"
2020
}
2121
],

Assets/Object Pooler/Runtime/ObjectPooling.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#region Statements
22

3-
#if !MIRROR
3+
#if MIRAGE
44
using Mirage;
55
#else
66
using Mirror;

Assets/Object Pooler/Runtime/ObjectPoolingManager.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
using System.Collections.Generic;
22
using UnityEngine;
33
using Object = UnityEngine.Object;
4-
using System;
5-
#if !MIRROR
4+
#if MIRAGE
65
using Mirage;
76
#else
87
using Mirror;
@@ -14,7 +13,7 @@ public class ObjectPoolingManager : MonoBehaviour
1413
{
1514
#region Fields
1615

17-
#if !MIRROR
16+
#if MIRAGE
1817
private ServerObjectManager _serverObjectManager;
1918
private readonly Dictionary<int?, NetworkIdentity> _objectsAssetIds = new Dictionary<int?, NetworkIdentity>();
2019
#else
@@ -32,7 +31,7 @@ private void Start()
3231
{
3332
_parent = new GameObject { name = "Pooled Objects" };
3433
DontDestroyOnLoad(_parent);
35-
#if !MIRROR
34+
#if MIRAGE
3635
_serverObjectManager = FindObjectOfType<ServerObjectManager>();
3736

3837
ClientObjectManager clientObject = FindObjectOfType<ClientObjectManager>();
@@ -59,7 +58,7 @@ private void Start()
5958

6059
#region Custom Spawn Handlers
6160

62-
#if !MIRROR
61+
#if MIRAGE
6362
/// <summary>
6463
/// Spawn handler for all network spawning of things.
6564
/// </summary>
@@ -76,8 +75,8 @@ internal NetworkIdentity SpawnObject(SpawnMessage msg)
7675
internal GameObject SpawnObject(Vector3 position, Guid assetId)
7776
#endif
7877
{
79-
#if !MIRROR
80-
NetworkIdentity spawnedObject = NetworkSpawnPool(msg.position, Quaternion.identity, msg.prefabHash, 1);
78+
#if MIRAGE
79+
NetworkIdentity spawnedObject = NetworkSpawnPool(msg.position ?? new Vector3(), Quaternion.identity, msg.prefabHash, 1);
8180
#else
8281
NetworkIdentity spawnedObject = NetworkSpawnPool(position, Quaternion.identity, assetId, 1);
8382
#endif
@@ -86,7 +85,7 @@ internal GameObject SpawnObject(Vector3 position, Guid assetId)
8685
spawnedObject.gameObject.SetActive(true);
8786

8887
// return the game object back to mirage to have it finish spawning.
89-
#if !MIRROR
88+
#if MIRAGE
9089
return spawnedObject;
9190
#else
9291
return spawnedObject.gameObject;
@@ -97,7 +96,7 @@ internal GameObject SpawnObject(Vector3 position, Guid assetId)
9796
/// Spawn handler for all network unspawning of things.
9897
/// </summary>
9998
/// <param name="spawned">What network identity we are going to unspawn and return back to network pool.</param>
100-
#if !MIRROR
99+
#if MIRAGE
101100
internal void UnSpawnObject(NetworkIdentity spawned)
102101
#else
103102
internal void UnSpawnObject(GameObject spawned)
@@ -113,7 +112,7 @@ internal void UnSpawnObject(GameObject spawned)
113112

114113
break;
115114
}
116-
#if !MIRROR
115+
#if MIRAGE
117116

118117
p.Despawn(spawned);
119118
#else
@@ -154,7 +153,7 @@ private void UnSpawnObject<T>(T spawned) where T : Object
154153
/// <param name="AssetId">The asset id of the object from <see cref="NetworkIdentity" /> to use to spawn object of.</param>
155154
/// <param name="quantity">How many pooled objects we want to create of this object. If we don't have a pool started.</param>
156155
/// <returns></returns>
157-
#if !MIRROR
156+
#if MIRAGE
158157
public NetworkIdentity NetworkSpawnPool(Vector3 position, Quaternion rotation, int? AssetId, int quantity = 3)
159158
#else
160159
public NetworkIdentity NetworkSpawnPool(Vector3 position, Quaternion rotation, Guid AssetId, int quantity = 3)
@@ -186,7 +185,7 @@ public void NetworkUnSpawnObject(NetworkIdentity objectSpawned, bool isServer)
186185
{
187186
UnSpawnObject(objectSpawned);
188187

189-
#if !MIRROR
188+
#if MIRAGE
190189
// If this is network server then tell rest of clients to unspawn object.
191190
if (_serverObjectManager == null || !isServer) return;
192191

0 commit comments

Comments
 (0)