From 3d46d9f511ce05819507059fae1717d533dfb4b9 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Mon, 1 Nov 2021 19:52:51 +0000 Subject: [PATCH 1/3] perf(Visibility): adding SpatialHash components --- .../Components/Visibility/SpatialHash.meta | 8 + .../SpatialHash/SpatialHashSystem.cs | 238 ++++++++++++++++++ .../SpatialHash/SpatialHashSystem.cs.meta | 11 + .../SpatialHash/SpatialHashVisibility.cs | 41 +++ .../SpatialHash/SpatialHashVisibility.cs.meta | 11 + 5 files changed, 309 insertions(+) create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash.meta create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs.meta create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs.meta diff --git a/Assets/Mirage/Components/Visibility/SpatialHash.meta b/Assets/Mirage/Components/Visibility/SpatialHash.meta new file mode 100644 index 00000000000..532fbc8a0b9 --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfeca0b13b830434a890072ea27e57ec +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs new file mode 100644 index 00000000000..0dcd2f63391 --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs @@ -0,0 +1,238 @@ +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using UnityEngine; + +namespace Mirage.Visibility.SpatialHash +{ + internal static class SpatialHashExtensions + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static Vector2 ToXZ(this Vector3 v) => new Vector2(v.x, v.z); + } + + public class SpatialHashSystem : MonoBehaviour + { + public NetworkServer Server; + + /// + /// How often (in seconds) that this object should update the list of observers that can see it. + /// + [Tooltip("How often (in seconds) that this object should update the list of observers that can see it.")] + public float VisibilityUpdateInterval = 1; + + [Tooltip("height and width of 1 box in grid")] + public float gridSize = 10; + + public Vector2 Centre = new Vector2(0, 0); + + [Tooltip("Bounds of the map used to calculate visibility. Objects out side of grid will not be visibility")] + public Vector2 Size = new Vector2(100, 100); + + // todo is list vs hashset better? Set would be better for remove objects, list would be better for looping + List all = new List(); + public GridHolder Grid; + + + public void Awake() + { + Server.Started.AddListener(() => + { + Server.World.onSpawn += World_onSpawn; + Server.World.onUnspawn += World_onUnspawn; + + // skip first invoke, list will be empty + InvokeRepeating(nameof(RebuildObservers), VisibilityUpdateInterval, VisibilityUpdateInterval); + + Grid = new GridHolder(gridSize, Centre, Size); + }); + + Server.Stopped.AddListener(() => + { + CancelInvoke(nameof(RebuildObservers)); + Grid = null; + }); + } + + private void World_onSpawn(NetworkIdentity identity) + { + NetworkVisibility visibility = identity.Visibility; + if (visibility is SpatialHashVisibility obj) + { + obj.System = this; + all.Add(obj); + } + } + private void World_onUnspawn(NetworkIdentity identity) + { + NetworkVisibility visibility = identity.Visibility; + if (visibility is SpatialHashVisibility obj) + { + all.Remove(obj); + } + } + + void RebuildObservers() + { + ClearGrid(); + AddPlayersToGrid(); + + foreach (SpatialHashVisibility obj in all) + { + obj.Identity.RebuildObservers(false); + } + } + + private void ClearGrid() + { + for (int i = 0; i < Grid.Width; i++) + { + for (int j = 0; j < Grid.Width; j++) + { + HashSet set = Grid.GetObjects(i, j); + if (set != null) + { + set.Clear(); + } + } + } + } + + private void AddPlayersToGrid() + { + foreach (INetworkPlayer player in Server.Players) + { + if (!player.HasCharacter) + continue; + + Vector2 position = player.Identity.transform.position.ToXZ(); + Grid.AddObject(position, player); + } + } + + + public class GridHolder + { + public readonly int Width; + public readonly int Height; + public readonly float GridSize; + public readonly Vector2 Centre; + public readonly Vector2 Size; + + public readonly GridPoint[] Points; + + public GridHolder(float gridSize, Vector2 centre, Vector2 size) + { + Centre = centre; + Size = size; + Width = Mathf.CeilToInt(size.x / gridSize); + Height = Mathf.CeilToInt(size.y / gridSize); + GridSize = gridSize; + + Points = new GridPoint[Width * Height]; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void AddObject(Vector2 position, T obj) + { + ToGridIndex(position, out int x, out int y); + AddObject(x, y, obj); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void AddObject(int i, int j, T obj) + { + int index = i + j * Width; + if (Points[index].objects == null) + { + Points[index].objects = new HashSet(); + } + + Points[index].objects.Add(obj); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public HashSet GetObjects(int i, int j) + { + return Points[i + j * Width].objects; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void CreateSet(int i, int j) + { + Points[i + j * Width].objects = new HashSet(); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool InBounds(Vector2 position) + { + float x = position.x - Centre.x; + float y = position.y - Centre.y; + + return (0 < x && x < Size.x) + && (0 < y && y < Size.y); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool InBounds(int x, int y) + { + return (0 < x && x < Width) + && (0 < y && y < Height); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool IsVisible(Vector2 target, Vector2 player, int range) + { + // if either is out of bounds, not visible + if (!InBounds(target) || !InBounds(player)) return false; + + ToGridIndex(target, out int xt, out int yt); + ToGridIndex(player, out int xp, out int yp); + + return AreClose(xt, xp, range) && AreClose(yt, yp, range); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + bool AreClose(int a, int b, int range) + { + int min = a - range; + int max = a + range; + + return max <= b && b <= min; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void ToGridIndex(Vector2 position, out int x, out int y) + { + float fx = position.x - Centre.x; + float fy = position.y - Centre.y; + + x = Mathf.RoundToInt(fx / GridSize); + y = Mathf.RoundToInt(fy / GridSize); + } + + public void BuildObservers(HashSet observers, Vector2 position, int range) + { + // not visible if not in range + if (!InBounds(position)) + return; + + ToGridIndex(position - Centre, out int x, out int y); + + for (int i = x - range; i <= x + range; i++) + { + for (int j = y - range; j <= y + range; j++) + { + if (InBounds(i, j)) + { + observers.UnionWith(GetObjects(i, j)); + } + } + } + } + + public struct GridPoint + { + public HashSet objects; + } + } + } +} diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs.meta b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs.meta new file mode 100644 index 00000000000..572f712a843 --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 92208a774ad18fd4ab07187078fc495d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs new file mode 100644 index 00000000000..4ee0cd466bd --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using Mirage.Logging; +using UnityEngine; + +namespace Mirage.Visibility.SpatialHash +{ + public class SpatialHashVisibility : NetworkVisibility + { + static readonly ILogger logger = LogFactory.GetLogger(typeof(SpatialHashVisibility)); + + [Tooltip("How many grid away the player can be to see this object. Real distance is this mutlipled by SpatialHashSystem")] + public int GridVisibleRange = 1; + + public SpatialHashSystem System; + + /// Network connection of a player. + /// True if the player can see this object. + public override bool OnCheckObserver(INetworkPlayer player) + { + if (player.Identity == null) + return false; + + + Vector2 thisPosition = transform.position.ToXZ(); + Vector2 playerPosition = player.Identity.transform.position.ToXZ(); + + return System.Grid.IsVisible(thisPosition, playerPosition, GridVisibleRange); + } + + /// + /// Callback used by the visibility system to (re)construct the set of observers that can see this object. + /// Implementations of this callback should add network connections of players that can see this object to the observers set. + /// + /// The new set of observers for this object. + /// True if the set of observers is being built for the first time. + public override void OnRebuildObservers(HashSet observers, bool initialize) + { + System.Grid.BuildObservers(observers, transform.position.ToXZ(), GridVisibleRange); + } + } +} diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs.meta b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs.meta new file mode 100644 index 00000000000..25a2b2f9976 --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d10af5e22d6a3f449974d5c78f5eb4df +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 44270d6c880a9a000811c21c83cedb315ecffd00 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Sat, 30 Apr 2022 21:31:47 +0100 Subject: [PATCH 2/3] improving spatialhash --- .../SpatialHash/SpatialHashSystem.cs | 88 +++++++----- .../SpatialHash/SpatialHashSystemEditor.cs | 131 ++++++++++++++++++ .../SpatialHashSystemEditor.cs.meta | 11 ++ .../SpatialHash/SpatialHashVisibility.cs | 14 ++ 4 files changed, 213 insertions(+), 31 deletions(-) create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs create mode 100644 Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs.meta diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs index 0dcd2f63391..57daf2a88c2 100644 --- a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystem.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using UnityEngine; @@ -8,6 +9,8 @@ internal static class SpatialHashExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Vector2 ToXZ(this Vector3 v) => new Vector2(v.x, v.z); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal static Vector3 FromXZ(this Vector2 v) => new Vector3(v.x, 0, v.y); } public class SpatialHashSystem : MonoBehaviour @@ -20,19 +23,16 @@ public class SpatialHashSystem : MonoBehaviour [Tooltip("How often (in seconds) that this object should update the list of observers that can see it.")] public float VisibilityUpdateInterval = 1; - [Tooltip("height and width of 1 box in grid")] - public float gridSize = 10; - - public Vector2 Centre = new Vector2(0, 0); - [Tooltip("Bounds of the map used to calculate visibility. Objects out side of grid will not be visibility")] - public Vector2 Size = new Vector2(100, 100); + public Bounds Bounds = new Bounds(Vector3.zero, 100 * Vector3.one); + + [Tooltip("How many points to split the grid into (in each xz axis)")] + public Vector2Int GridCount = Vector2Int.one * 10; // todo is list vs hashset better? Set would be better for remove objects, list would be better for looping List all = new List(); public GridHolder Grid; - public void Awake() { Server.Started.AddListener(() => @@ -43,7 +43,7 @@ public void Awake() // skip first invoke, list will be empty InvokeRepeating(nameof(RebuildObservers), VisibilityUpdateInterval, VisibilityUpdateInterval); - Grid = new GridHolder(gridSize, Centre, Size); + Grid = new GridHolder(Bounds, GridCount); }); Server.Stopped.AddListener(() => @@ -58,6 +58,7 @@ private void World_onSpawn(NetworkIdentity identity) NetworkVisibility visibility = identity.Visibility; if (visibility is SpatialHashVisibility obj) { + Debug.Assert(obj.System == null); obj.System = this; all.Add(obj); } @@ -67,6 +68,8 @@ private void World_onUnspawn(NetworkIdentity identity) NetworkVisibility visibility = identity.Visibility; if (visibility is SpatialHashVisibility obj) { + Debug.Assert(obj.System == this); + obj.System = null; all.Remove(obj); } } @@ -114,19 +117,23 @@ public class GridHolder { public readonly int Width; public readonly int Height; - public readonly float GridSize; - public readonly Vector2 Centre; + public readonly Vector2 Offset; public readonly Vector2 Size; + public readonly Vector2 Extents; + public readonly Vector2 GridSize; public readonly GridPoint[] Points; - public GridHolder(float gridSize, Vector2 centre, Vector2 size) + public GridHolder(Bounds bounds, Vector2Int gridCount) { - Centre = centre; - Size = size; - Width = Mathf.CeilToInt(size.x / gridSize); - Height = Mathf.CeilToInt(size.y / gridSize); - GridSize = gridSize; + Offset = (bounds.center - bounds.extents).ToXZ(); + Size = bounds.size.ToXZ(); + Extents = bounds.extents.ToXZ(); + + Width = gridCount.x; + Height = gridCount.y; + + GridSize = Size / gridCount; Points = new GridPoint[Width * Height]; } @@ -134,8 +141,11 @@ public GridHolder(float gridSize, Vector2 centre, Vector2 size) [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddObject(Vector2 position, T obj) { - ToGridIndex(position, out int x, out int y); - AddObject(x, y, obj); + if (InBounds(position)) + { + ToGridIndex(position, out int x, out int y); + AddObject(x, y, obj); + } } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -153,6 +163,12 @@ public void AddObject(int i, int j, T obj) [MethodImpl(MethodImplOptions.AggressiveInlining)] public HashSet GetObjects(int i, int j) { +#if DEBUG + if (i < 0) throw new IndexOutOfRangeException($"i ({i}) is less than zero"); + if (j < 0) throw new IndexOutOfRangeException($"j ({j}) is less than zero"); + if (i >= Width) throw new IndexOutOfRangeException($"i ({i}) is greater than {Width}"); + if (j >= Height) throw new IndexOutOfRangeException($"j ({j}) is greater than {Height}"); +#endif return Points[i + j * Width].objects; } @@ -165,17 +181,15 @@ public void CreateSet(int i, int j) [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool InBounds(Vector2 position) { - float x = position.x - Centre.x; - float y = position.y - Centre.y; - - return (0 < x && x < Size.x) - && (0 < y && y < Size.y); + return (-Extents.x <= position.x && position.x <= Extents.x) + && (-Extents.y <= position.y && position.y <= Extents.y); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool InBounds(int x, int y) { - return (0 < x && x < Width) - && (0 < y && y < Height); + // inclusive lower bound + return (0 <= x && x < Width) + && (0 <= y && y < Height); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -202,11 +216,11 @@ bool AreClose(int a, int b, int range) [MethodImpl(MethodImplOptions.AggressiveInlining)] public void ToGridIndex(Vector2 position, out int x, out int y) { - float fx = position.x - Centre.x; - float fy = position.y - Centre.y; + float fx = position.x - Offset.x; + float fy = position.y - Offset.y; - x = Mathf.RoundToInt(fx / GridSize); - y = Mathf.RoundToInt(fy / GridSize); + x = Mathf.RoundToInt(fx / GridSize.x); + y = Mathf.RoundToInt(fy / GridSize.y); } public void BuildObservers(HashSet observers, Vector2 position, int range) @@ -215,7 +229,7 @@ public void BuildObservers(HashSet observers, Vector2 position, int range) if (!InBounds(position)) return; - ToGridIndex(position - Centre, out int x, out int y); + ToGridIndex(position, out int x, out int y); for (int i = x - range; i <= x + range; i++) { @@ -223,12 +237,24 @@ public void BuildObservers(HashSet observers, Vector2 position, int range) { if (InBounds(i, j)) { - observers.UnionWith(GetObjects(i, j)); + HashSet set = GetObjects(i, j); + if (set != null) + UnionWithNonAlloc(observers, set); } } } } + void UnionWithNonAlloc(HashSet first, HashSet second) + { + HashSet.Enumerator enumerator = second.GetEnumerator(); + while (enumerator.MoveNext()) + { + first.Add(enumerator.Current); + } + enumerator.Dispose(); + } + public struct GridPoint { public HashSet objects; diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs new file mode 100644 index 00000000000..f047704292e --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs @@ -0,0 +1,131 @@ +using UnityEngine; + +#if UNITY_EDITOR +namespace Mirage.Visibility.SpatialHash.EditorScripts +{ + using System.Collections.Generic; + using UnityEditor; + using UnityEditor.IMGUI.Controls; + + [CustomEditor(typeof(SpatialHashSystem))] + public class SpatialHashSystemEditor : Editor + { + const PrimitiveBoundsHandle.Axes BoundsAxis = PrimitiveBoundsHandle.Axes.X | PrimitiveBoundsHandle.Axes.Z; + + BoxBoundsHandle boundsHandle = new BoxBoundsHandle() { axes = BoundsAxis }; + + // cache array for drawing handle + readonly Vector3[] verts = new Vector3[4]; + + readonly List playerPositions = new List(); + + public void OnSceneGUI() + { + var system = target as SpatialHashSystem; + var bounds = new Rect(system.Bounds.center.ToXZ(), system.Bounds.size.ToXZ()); + Vector2Int points = system.GridCount; + GetPlayerPos(system); + + DrawGrid(bounds, points, playerPositions); + DrawBoundsHandle(system); + } + + private void GetPlayerPos(SpatialHashSystem system) + { + playerPositions.Clear(); + + NetworkServer server = system.Server; + if (server != null && server.Active) + { + foreach (INetworkPlayer player in server.Players) + { + if (player.HasCharacter) + { + NetworkIdentity character = player.Identity; + playerPositions.Add(character.transform.position); + } + } + + // return here, dont need to check client if we are server + return; + } + + NetworkClient client = system.GetComponent(); + if (client != null && client.Active) + { + if (client.Player != null && client.Player.HasCharacter) + { + NetworkIdentity character = client.Player.Identity; + playerPositions.Add(character.transform.position); + return; + + } + } + } + + private void DrawGrid(Rect bounds, Vector2Int points, List players) + { + Vector2 offset = bounds.center - bounds.size; + Vector2 size = bounds.size; + + var gridSize = new Vector2(size.x / points.x, size.y / points.y); + Vector2 halfGrid = gridSize / 2; + + bool colorFlip = false; + for (int i = 0; i < points.x; i++) + { + for (int j = 0; j < points.y; j++) + { + float x = i * gridSize.x; + float y = j * gridSize.y; + + // center of 1 gridPoint + Vector2 pos2d = new Vector2(x, y) + halfGrid + offset; + Vector3 pos = pos2d.FromXZ(); + + // +- halfGrid to get corners + verts[0] = pos + new Vector3(-halfGrid.x, 0, -halfGrid.y); + verts[1] = pos + new Vector3(-halfGrid.x, 0, +halfGrid.y); + verts[2] = pos + new Vector3(+halfGrid.x, 0, +halfGrid.y); + verts[3] = pos + new Vector3(+halfGrid.x, 0, -halfGrid.y); + + Color color = Color.gray * (colorFlip ? 1 : 0.7f); + + foreach (Vector3 player in players) + { + var gridRect = new Rect(x + offset.x, y + offset.y, gridSize.x, gridSize.y); + if (gridRect.Contains(player.ToXZ())) + { + // not too red + color = Color.red * 0.5f; + break; + } + } + + // transparent + color.a = 0.6f; + Handles.DrawSolidRectangleWithOutline(verts, color, Color.black); + colorFlip = !colorFlip; + } + // if even we need to re-flip so that color is samme as last one, but will be different than above it + if (points.y % 2 == 0) + colorFlip = !colorFlip; + } + } + + private void DrawBoundsHandle(SpatialHashSystem system) + { + boundsHandle.center = system.Bounds.center; + boundsHandle.size = system.Bounds.size; + EditorGUI.BeginChangeCheck(); + boundsHandle.DrawHandle(); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(system, "Change Bounds"); + system.Bounds.center = boundsHandle.center; + system.Bounds.size = boundsHandle.size; + } + } + } +} +#endif diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs.meta b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs.meta new file mode 100644 index 00000000000..b2dfa77b467 --- /dev/null +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashSystemEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c4328cadef352544493ca63bfe216eb7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs index 4ee0cd466bd..0ec63206e06 100644 --- a/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs +++ b/Assets/Mirage/Components/Visibility/SpatialHash/SpatialHashVisibility.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Mirage.Logging; using UnityEngine; @@ -11,12 +12,15 @@ public class SpatialHashVisibility : NetworkVisibility [Tooltip("How many grid away the player can be to see this object. Real distance is this mutlipled by SpatialHashSystem")] public int GridVisibleRange = 1; + [ReadOnlyInspector] public SpatialHashSystem System; /// Network connection of a player. /// True if the player can see this object. public override bool OnCheckObserver(INetworkPlayer player) { + ThrowIfNoSystem(); + if (player.Identity == null) return false; @@ -35,7 +39,17 @@ public override bool OnCheckObserver(INetworkPlayer player) /// True if the set of observers is being built for the first time. public override void OnRebuildObservers(HashSet observers, bool initialize) { + ThrowIfNoSystem(); + System.Grid.BuildObservers(observers, transform.position.ToXZ(), GridVisibleRange); } + + private void ThrowIfNoSystem() + { + if (System is null) + { + throw new InvalidOperationException("No SpatialHashSystem Set on SpatialHashVisibility. Add SpatialHashSystem to your NetworkManager before using this component."); + } + } } } From 03010db84295b3b6ec0accc32c54ed5fbb745216 Mon Sep 17 00:00:00 2001 From: James Frowen Date: Sat, 30 Apr 2022 21:32:02 +0100 Subject: [PATCH 3/3] example for visibility --- Assets/Mirage/Samples~/CoinVisibility.meta | 8 + .../Mirage/Samples~/CoinVisibility/Coin.mat | 77 ++ .../Samples~/CoinVisibility/Coin.mat.meta | 8 + .../Samples~/CoinVisibility/Coin.prefab | 206 ++++++ .../Samples~/CoinVisibility/Coin.prefab.meta | 7 + .../Samples~/CoinVisibility/CoinSpin.cs | 43 ++ .../Samples~/CoinVisibility/CoinSpin.cs.meta | 11 + .../CoinVisibility/CoinVisibility.unity | 662 ++++++++++++++++++ .../CoinVisibility/CoinVisibility.unity.meta | 7 + .../Mirage/Samples~/CoinVisibility/Floor.mat | 77 ++ .../Samples~/CoinVisibility/Floor.mat.meta | 8 + .../Samples~/CoinVisibility/Player.prefab | 508 ++++++++++++++ .../CoinVisibility/Player.prefab.meta | 7 + .../Samples~/CoinVisibility/Player1.mat | 77 ++ .../Samples~/CoinVisibility/Player1.mat.meta | 8 + .../Samples~/CoinVisibility/PlayerBack.mat | 77 ++ .../CoinVisibility/PlayerBack.mat.meta | 8 + .../Samples~/CoinVisibility/PlayerMove.cs | 18 + .../CoinVisibility/PlayerMove.cs.meta | 11 + .../Samples~/CoinVisibility/PlayeyArm.mat | 77 ++ .../CoinVisibility/PlayeyArm.mat.meta | 8 + .../CoinVisibility/SpawnCoinsGrids.cs | 47 ++ .../CoinVisibility/SpawnCoinsGrids.cs.meta | 11 + 23 files changed, 1971 insertions(+) create mode 100644 Assets/Mirage/Samples~/CoinVisibility.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Coin.mat create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Coin.mat.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Coin.prefab create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Coin.prefab.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs create mode 100644 Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity create mode 100644 Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Floor.mat create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Floor.mat.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Player.prefab create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Player.prefab.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Player1.mat create mode 100644 Assets/Mirage/Samples~/CoinVisibility/Player1.mat.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat create mode 100644 Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs create mode 100644 Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat create mode 100644 Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat.meta create mode 100644 Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs create mode 100644 Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs.meta diff --git a/Assets/Mirage/Samples~/CoinVisibility.meta b/Assets/Mirage/Samples~/CoinVisibility.meta new file mode 100644 index 00000000000..afd7cad1035 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 44aeb3f53834ddc438e4cd5b44c972df +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/Coin.mat b/Assets/Mirage/Samples~/CoinVisibility/Coin.mat new file mode 100644 index 00000000000..42e69d51037 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Coin.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Coin + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.706 + - _GlossyReflections: 1 + - _Metallic: 0.894 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0.96867794, b: 0.5176471, a: 1} + - _EmissionColor: {r: 0.57434916, g: 0.57434916, b: 0.57434916, a: 1} diff --git a/Assets/Mirage/Samples~/CoinVisibility/Coin.mat.meta b/Assets/Mirage/Samples~/CoinVisibility/Coin.mat.meta new file mode 100644 index 00000000000..3ded1e7a359 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Coin.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ba5c13e68e7f2b94cbd682aaf19a1a37 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/Coin.prefab b/Assets/Mirage/Samples~/CoinVisibility/Coin.prefab new file mode 100644 index 00000000000..572db10f164 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Coin.prefab @@ -0,0 +1,206 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &3864512206185586390 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1100274980167397228} + - component: {fileID: 7868806739205968279} + - component: {fileID: 4607425252360599346} + - component: {fileID: 8784247804438465526} + m_Layer: 0 + m_Name: Coin + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1100274980167397228 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3864512206185586390} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 7526867810867754005} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &7868806739205968279 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3864512206185586390} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3} + m_Name: + m_EditorClassIdentifier: + SpawnSettings: + SendPosition: 1 + SendRotation: 0 + SendScale: 0 + _sceneId: 0 + ServerObjectManager: {fileID: 0} + ClientObjectManager: {fileID: 0} + _prefabHash: 418735174 + _onStartServer: + _event: + m_PersistentCalls: + m_Calls: [] + _onStartClient: + _event: + m_PersistentCalls: + m_Calls: [] + _onStartLocalPlayer: + _event: + m_PersistentCalls: + m_Calls: [] + _onAuthorityChanged: + _event: + m_PersistentCalls: + m_Calls: [] + _onStopClient: + _event: + m_PersistentCalls: + m_Calls: [] + _onStopServer: + _event: + m_PersistentCalls: + m_Calls: [] + hasSpawned: 0 +--- !u!114 &4607425252360599346 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3864512206185586390} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 60a68fc27e7f3e9439ff23d9436d8346, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + Speed: 90 +--- !u!114 &8784247804438465526 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3864512206185586390} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d10af5e22d6a3f449974d5c78f5eb4df, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + GridVisibleRange: 1 + System: {fileID: 0} +--- !u!1 &5245661298838390930 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7526867810867754005} + - component: {fileID: 3483331364365409195} + - component: {fileID: 5851277452832196472} + - component: {fileID: 51410167167631800} + m_Layer: 0 + m_Name: Cylinder + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7526867810867754005 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5245661298838390930} + m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.5, y: 0.05, z: 0.5} + m_Children: [] + m_Father: {fileID: 1100274980167397228} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90} +--- !u!33 &3483331364365409195 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5245661298838390930} + m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &5851277452832196472 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5245661298838390930} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: ba5c13e68e7f2b94cbd682aaf19a1a37, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!136 &51410167167631800 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5245661298838390930} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5000001 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697} diff --git a/Assets/Mirage/Samples~/CoinVisibility/Coin.prefab.meta b/Assets/Mirage/Samples~/CoinVisibility/Coin.prefab.meta new file mode 100644 index 00000000000..ffa81d0e958 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Coin.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 68f8fe908f4543d4786968457282059f +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs b/Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs new file mode 100644 index 00000000000..89884449697 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs @@ -0,0 +1,43 @@ +using Mirage; +using Mirage.Serialization; +using UnityEngine; + +namespace Examples.SpatialHash +{ + public class CoinSpin : NetworkBehaviour + { + static Transform Parent; + + public float Speed; + + [SyncVar(hook = nameof(OnRotationChanged)), FloatPack(180, 0.1f)] float Rotation; + + private void OnRotationChanged(float _) + { + if (IsClientOnly) // dont change if again if host + transform.rotation = Quaternion.AngleAxis(Rotation, Vector3.up); + } + + private void Awake() + { + // start random so not all coins have same angle + Rotation = Random.Range(-180f, 180f); + + if (Parent == null) + Parent = new GameObject("Coin Parent").transform; + + this.transform.parent = Parent; + } + + private void FixedUpdate() + { + if (IsServer) + { + Rotation += (Speed * Time.fixedDeltaTime); + if (Rotation > 180) + Rotation -= 360f; + transform.rotation = Quaternion.AngleAxis(Rotation, Vector3.up); + } + } + } +} diff --git a/Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs.meta b/Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs.meta new file mode 100644 index 00000000000..86d3240ef29 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/CoinSpin.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 60a68fc27e7f3e9439ff23d9436d8346 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity b/Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity new file mode 100644 index 00000000000..9fa1d9e1058 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity @@ -0,0 +1,662 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &97544163 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 97544174} + - component: {fileID: 97544173} + - component: {fileID: 97544172} + - component: {fileID: 97544171} + - component: {fileID: 97544170} + - component: {fileID: 97544169} + - component: {fileID: 97544168} + - component: {fileID: 97544167} + - component: {fileID: 97544166} + - component: {fileID: 97544165} + - component: {fileID: 97544164} + - component: {fileID: 97544175} + m_Layer: 0 + m_Name: NetworkManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &97544164 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 81da5905cb362874ba7cbe36247debba, type: 3} + m_Name: + m_EditorClassIdentifier: + NetworkManager: {fileID: 97544173} + NetworkAddress: localhost + Scale: 1 + GUIAnchor: 0 +--- !u!114 &97544165 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9e877e0fe6eaef047be75023492516ee, type: 3} + m_Name: + m_EditorClassIdentifier: + CoinPrefab: {fileID: 3864512206185586390, guid: 68f8fe908f4543d4786968457282059f, + type: 3} + Server: {fileID: 97544172} + ServerObjectManager: {fileID: 97544170} + gridSize: 3 + gridExtends: {x: 29, y: 29} +--- !u!114 &97544166 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac6e8eccf4b6f4dc7b24c276ef47fde8, type: 3} + m_Name: + m_EditorClassIdentifier: + settings: {fileID: 11400000, guid: a32efd20b21c8f84ea7d413961eb7766, type: 2} +--- !u!114 &97544167 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d9f46b2d67d7a054d8c13075473bd4a2, type: 3} + m_Name: + m_EditorClassIdentifier: + Address: localhost + Port: 7777 + SocketLib: 0 + BufferSize: 262144 +--- !u!114 &97544168 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a7aaac73a16c040fd871cb977b5c557b, type: 3} + m_Name: + m_EditorClassIdentifier: + Client: {fileID: 97544171} + Server: {fileID: 97544172} + SceneManager: {fileID: 0} + ClientObjectManager: {fileID: 97544169} + ServerObjectManager: {fileID: 97544170} + PlayerPrefab: {fileID: 6431530665847088234, guid: cbb263f993672284b8f3d073548567e2, + type: 3} + AutoSpawn: 1 + startPositionIndex: 0 + startPositions: [] + playerSpawnMethod: 0 +--- !u!114 &97544169 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a2cbc85c1c2f1c249bbe95ae110bbcde, type: 3} + m_Name: + m_EditorClassIdentifier: + Client: {fileID: 97544171} + NetworkSceneManager: {fileID: 0} + spawnPrefabs: + - {fileID: 7868806739205968279, guid: 68f8fe908f4543d4786968457282059f, type: 3} + - {fileID: 6431530665847088234, guid: cbb263f993672284b8f3d073548567e2, type: 3} +--- !u!114 &97544170 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b750203ddb2d9f84abd799a5c2c32cb6, type: 3} + m_Name: + m_EditorClassIdentifier: + Server: {fileID: 97544172} + NetworkSceneManager: {fileID: 0} +--- !u!114 &97544171 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: abe6be14204d94224a3e7cd99dd2ea73, type: 3} + m_Name: + m_EditorClassIdentifier: + EnablePeerMetrics: 0 + MetricsSize: 10 + SocketFactory: {fileID: 97544167} + DisconnectOnException: 1 + authenticator: {fileID: 0} + _started: + _event: + m_PersistentCalls: + m_Calls: [] + _connected: + _event: + m_PersistentCalls: + m_Calls: [] + _authenticated: + _event: + m_PersistentCalls: + m_Calls: [] + _disconnected: + _event: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &97544172 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a5f5ec068f5604c32b160bc49ee97b75, type: 3} + m_Name: + m_EditorClassIdentifier: + EnablePeerMetrics: 0 + MetricsSize: 10 + MaxConnections: 4 + DisconnectOnException: 1 + Listening: 1 + SocketFactory: {fileID: 97544167} + authenticator: {fileID: 0} + _started: + _event: + m_PersistentCalls: + m_Calls: [] + _connected: + m_PersistentCalls: + m_Calls: [] + _authenticated: + m_PersistentCalls: + m_Calls: [] + _disconnected: + m_PersistentCalls: + m_Calls: [] + _stopped: + _event: + m_PersistentCalls: + m_Calls: [] + _onStartHost: + _event: + m_PersistentCalls: + m_Calls: [] + _onStopHost: + _event: + m_PersistentCalls: + m_Calls: [] +--- !u!114 &97544173 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8aab4c8111b7c411b9b92cf3dbc5bd4e, type: 3} + m_Name: + m_EditorClassIdentifier: + Server: {fileID: 97544172} + Client: {fileID: 97544171} + NetworkSceneManager: {fileID: 0} + ServerObjectManager: {fileID: 97544170} + ClientObjectManager: {fileID: 97544169} +--- !u!4 &97544174 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &97544175 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 97544163} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 92208a774ad18fd4ab07187078fc495d, type: 3} + m_Name: + m_EditorClassIdentifier: + Server: {fileID: 97544172} + VisibilityUpdateInterval: 0.1 + Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 30, y: 0, z: 30} + GridCount: {x: 10, y: 10} +--- !u!1 &816791395 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 816791397} + - component: {fileID: 816791396} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &816791396 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 816791395} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &816791397 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 816791395} + m_LocalRotation: {x: 0.68724585, y: -0.54290235, z: 0.34319887, w: 0.3393595} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 57.045002, y: -190.941, z: -109.343} +--- !u!1 &1294950436 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1294950439} + - component: {fileID: 1294950438} + - component: {fileID: 1294950437} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1294950437 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1294950436} + m_Enabled: 1 +--- !u!20 &1294950438 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1294950436} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1294950439 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1294950436} + m_LocalRotation: {x: 0.57587874, y: -0, z: -0, w: 0.81753516} + m_LocalPosition: {x: 0, y: 44.3, z: -21.9} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 70.32201, y: 0, z: 0} +--- !u!1 &1577712984 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1577712988} + - component: {fileID: 1577712987} + - component: {fileID: 1577712986} + - component: {fileID: 1577712985} + m_Layer: 0 + m_Name: Floor + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!64 &1577712985 +MeshCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577712984} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 4 + m_Convex: 0 + m_CookingOptions: 30 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1577712986 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577712984} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 1a3b0dc2998ae6f419ad8fd219a38b55, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1577712987 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577712984} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1577712988 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1577712984} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: -1, z: 0} + m_LocalScale: {x: 6, y: 6, z: 6} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity.meta b/Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity.meta new file mode 100644 index 00000000000..51e6a2d0c71 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/CoinVisibility.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1afd61b6d09b6ab429903a144459dae9 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/Floor.mat b/Assets/Mirage/Samples~/CoinVisibility/Floor.mat new file mode 100644 index 00000000000..8422b0fb805 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Floor.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Floor + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.051664297, g: 0.4056604, b: 0.109921634, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Mirage/Samples~/CoinVisibility/Floor.mat.meta b/Assets/Mirage/Samples~/CoinVisibility/Floor.mat.meta new file mode 100644 index 00000000000..b2c8302eb7a --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Floor.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1a3b0dc2998ae6f419ad8fd219a38b55 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/Player.prefab b/Assets/Mirage/Samples~/CoinVisibility/Player.prefab new file mode 100644 index 00000000000..9016fa81538 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Player.prefab @@ -0,0 +1,508 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1105249586349289509 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8776246114093056883} + - component: {fileID: 2419155554292425511} + - component: {fileID: 7818423181377648717} + - component: {fileID: 1774250037791962477} + m_Layer: 0 + m_Name: Cube (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8776246114093056883 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1105249586349289509} + m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} + m_LocalPosition: {x: 0.4, y: 0.299, z: 0.623} + m_LocalScale: {x: 0.14995609, y: 1.4735, z: 0.14732218} + m_Children: [] + m_Father: {fileID: 7826765878716531060} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!33 &2419155554292425511 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1105249586349289509} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &7818423181377648717 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1105249586349289509} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d36bed2e7ba4ca04eb10227bca717971, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!65 &1774250037791962477 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1105249586349289509} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &2029001502446938071 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1008996913915590254} + - component: {fileID: 3936266753640402717} + - component: {fileID: 6668585117021985580} + - component: {fileID: 4320906258017620829} + m_Layer: 0 + m_Name: Cube (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1008996913915590254 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2029001502446938071} + m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} + m_LocalPosition: {x: -0.4, y: 0.299, z: 0.623} + m_LocalScale: {x: 0.14995609, y: 1.4735, z: 0.14732218} + m_Children: [] + m_Father: {fileID: 7826765878716531060} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!33 &3936266753640402717 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2029001502446938071} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &6668585117021985580 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2029001502446938071} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: d36bed2e7ba4ca04eb10227bca717971, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!65 &4320906258017620829 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2029001502446938071} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &2156292497215340326 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4100834533852348863} + - component: {fileID: 8141532140495973486} + - component: {fileID: 7607489373921001139} + - component: {fileID: 1239712554624734484} + m_Layer: 0 + m_Name: Capsule + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4100834533852348863 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2156292497215340326} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 7826765878716531060} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!33 &8141532140495973486 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2156292497215340326} + m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &7607489373921001139 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2156292497215340326} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: ebf29c7c1be17ee4a97dc1d616628e64, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!136 &1239712554624734484 +CapsuleCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2156292497215340326} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + m_Radius: 0.5 + m_Height: 2 + m_Direction: 1 + m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &5659418887853436693 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7826765878716531060} + - component: {fileID: 6431530665847088234} + - component: {fileID: -2553094474765757889} + - component: {fileID: 1782894591956031461} + - component: {fileID: -7027025301861827346} + m_Layer: 0 + m_Name: Player + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7826765878716531060 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5659418887853436693} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 4100834533852348863} + - {fileID: 7194591030764397901} + - {fileID: 8776246114093056883} + - {fileID: 1008996913915590254} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &6431530665847088234 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5659418887853436693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3} + m_Name: + m_EditorClassIdentifier: + SpawnSettings: + SendPosition: 1 + SendRotation: 1 + SendScale: 1 + _sceneId: 0 + ServerObjectManager: {fileID: 0} + ClientObjectManager: {fileID: 0} + _prefabHash: 1065410742 + _onStartServer: + _event: + m_PersistentCalls: + m_Calls: [] + _onStartClient: + _event: + m_PersistentCalls: + m_Calls: [] + _onStartLocalPlayer: + _event: + m_PersistentCalls: + m_Calls: [] + _onAuthorityChanged: + _event: + m_PersistentCalls: + m_Calls: [] + _onStopClient: + _event: + m_PersistentCalls: + m_Calls: [] + _onStopServer: + _event: + m_PersistentCalls: + m_Calls: [] + hasSpawned: 0 +--- !u!114 &-2553094474765757889 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5659418887853436693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5cf20b2c3dc793e4c9a522db17c22ece, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + Speed: 5 + RotateSpeed: 80 +--- !u!114 &1782894591956031461 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5659418887853436693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d10af5e22d6a3f449974d5c78f5eb4df, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + GridVisibleRange: 2 + System: {fileID: 0} +--- !u!114 &-7027025301861827346 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5659418887853436693} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2f74aedd71d9a4f55b3ce499326d45fb, type: 3} + m_Name: + m_EditorClassIdentifier: + syncMode: 0 + syncInterval: 0.1 + ClientAuthority: 1 + LocalPositionSensitivity: 0.01 + LocalRotationSensitivity: 0.01 + LocalScaleSensitivity: 0.01 +--- !u!1 &6489775389726820296 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7194591030764397901} + - component: {fileID: 6676058122020687910} + - component: {fileID: 4579591979874919957} + - component: {fileID: 3791335490613495711} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7194591030764397901 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6489775389726820296} + m_LocalRotation: {x: 0.20870288, y: -0, z: -0, w: 0.9779791} + m_LocalPosition: {x: 0, y: -0.007, z: -0.477} + m_LocalScale: {x: 0.71503, y: 1, z: 0.13195} + m_Children: [] + m_Father: {fileID: 7826765878716531060} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 24.093, y: 0, z: 0} +--- !u!33 &6676058122020687910 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6489775389726820296} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &4579591979874919957 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6489775389726820296} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: 5f786786385e26c499ea1747a3cc9bd9, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!65 &3791335490613495711 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6489775389726820296} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Mirage/Samples~/CoinVisibility/Player.prefab.meta b/Assets/Mirage/Samples~/CoinVisibility/Player.prefab.meta new file mode 100644 index 00000000000..001035dee71 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Player.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: cbb263f993672284b8f3d073548567e2 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/Player1.mat b/Assets/Mirage/Samples~/CoinVisibility/Player1.mat new file mode 100644 index 00000000000..5211f568a3f --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Player1.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Player1 + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 0.1451273, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Mirage/Samples~/CoinVisibility/Player1.mat.meta b/Assets/Mirage/Samples~/CoinVisibility/Player1.mat.meta new file mode 100644 index 00000000000..213d840c7ba --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/Player1.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ebf29c7c1be17ee4a97dc1d616628e64 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat b/Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat new file mode 100644 index 00000000000..5a7a9d1bd2e --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: PlayerBack + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 0.004719496, b: 0.3490566, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat.meta b/Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat.meta new file mode 100644 index 00000000000..1619afcbd0e --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/PlayerBack.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f786786385e26c499ea1747a3cc9bd9 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs b/Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs new file mode 100644 index 00000000000..6c9c2a9ffd5 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs @@ -0,0 +1,18 @@ +using Mirage; +using UnityEngine; + +namespace Examples.SpatialHash +{ + public class PlayerMove : NetworkBehaviour + { + [SerializeField] float Speed; + [SerializeField] float RotateSpeed; + + // Update is called once per frame + void Update() + { + transform.position += Input.GetAxis("Vertical") * Speed * transform.forward * Time.deltaTime; + transform.Rotate(Input.GetAxis("Horizontal") * RotateSpeed * Vector3.up * Time.deltaTime, Space.Self); + } + } +} diff --git a/Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs.meta b/Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs.meta new file mode 100644 index 00000000000..a22231ee797 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/PlayerMove.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5cf20b2c3dc793e4c9a522db17c22ece +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat b/Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat new file mode 100644 index 00000000000..9d6063804d3 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: PlayeyArm + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0, g: 0.27396652, b: 0.34901962, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat.meta b/Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat.meta new file mode 100644 index 00000000000..ba231d2dab7 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/PlayeyArm.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d36bed2e7ba4ca04eb10227bca717971 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs b/Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs new file mode 100644 index 00000000000..09f7a30dc0b --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs @@ -0,0 +1,47 @@ +using Cysharp.Threading.Tasks; +using Mirage; +using UnityEngine; + +namespace Examples.SpatialHash +{ + public class SpawnCoinsGrids : MonoBehaviour + { + public GameObject CoinPrefab; + public NetworkServer Server; + public ServerObjectManager ServerObjectManager; + + public float gridSize; + public Vector2 gridExtends; + + public void Awake() + { + Server.Started.AddListener(UniTask.UnityAction(ServerStarted)); + } + + private async UniTaskVoid ServerStarted() + { + await UniTask.Yield(); + + for (float x = 0; x < gridExtends.x; x += gridSize) + { + for (float y = 0; y < gridExtends.y; y += gridSize) + { + float halfGrid = gridSize / 2; + // spawn in all 4 quadrants + SpawnCoin(x + halfGrid, y + halfGrid); + SpawnCoin(x + halfGrid, -y - halfGrid); + SpawnCoin(-x - halfGrid, y + halfGrid); + SpawnCoin(-x - halfGrid, -y - halfGrid); + } + } + } + + private void SpawnCoin(float x, float y) + { + GameObject clone = Instantiate(CoinPrefab); + clone.transform.position = new Vector3(x, 0, y); + + ServerObjectManager.Spawn(clone); + } + } +} diff --git a/Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs.meta b/Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs.meta new file mode 100644 index 00000000000..86bd59b7422 --- /dev/null +++ b/Assets/Mirage/Samples~/CoinVisibility/SpawnCoinsGrids.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e877e0fe6eaef047be75023492516ee +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: