Merge pull request #3 from vis2k/master

Catchup
This commit is contained in:
MrGadget 2019-03-19 21:13:34 -04:00 committed by GitHub
commit 3ad6615f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
395 changed files with 12244 additions and 5489 deletions

13
.releaserc.yml Normal file
View File

@ -0,0 +1,13 @@
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "angular",
"releaseRules": [
{"type": "breaking", "release": "major"},
{"type": "feature", "release": "minor"},
]
}],
'@semantic-release/release-notes-generator',
'@semantic-release/github'
]
}

View File

@ -1,4 +1,3 @@
using System;
using UnityEngine;
namespace Mirror
@ -6,18 +5,21 @@ namespace Mirror
[DisallowMultipleComponent]
[AddComponentMenu("Network/NetworkAnimator")]
[RequireComponent(typeof(NetworkIdentity))]
[RequireComponent(typeof(Animator))]
[HelpURL("https://vis2k.github.io/Mirror/Components/NetworkAnimator")]
public class NetworkAnimator : NetworkBehaviour
{
// configuration
[SerializeField] Animator m_Animator;
[SerializeField] uint m_ParameterSendBits;
// Note: not an object[] array because otherwise initialization is real annoying
int[] lastIntParameters;
float[] lastFloatParameters;
bool[] lastBoolParameters;
// properties
public Animator animator
{
get { return m_Animator; }
get => m_Animator;
set
{
m_Animator = value;
@ -135,11 +137,12 @@ void CheckSendRate()
m_SendTimer = Time.time + syncInterval;
NetworkWriter writer = new NetworkWriter();
WriteParameters(writer, true);
if (WriteParameters(writer, true))
{
SendAnimationParametersMessage(writer.ToArray());
}
}
}
void SendAnimationMessage(int stateHash, float normalizedTime, byte[] parameters)
{
@ -194,12 +197,20 @@ internal void HandleAnimTriggerMsg(int hash)
m_Animator.SetTrigger(hash);
}
void WriteParameters(NetworkWriter writer, bool autoSend)
bool WriteParameters(NetworkWriter writer, bool autoSend)
{
// store the animator parameters in a variable - the "Animator.parameters" getter allocates
// a new parameter array every time it is accessed so we should avoid doing it in a loop
AnimatorControllerParameter[] parameters = m_Animator.parameters;
if (lastIntParameters == null) lastIntParameters = new int[parameters.Length];
if (lastFloatParameters == null) lastFloatParameters = new float[parameters.Length];
if (lastBoolParameters == null) lastBoolParameters = new bool[parameters.Length];
uint dirtyBits = 0;
// Save the position in the writer where to insert the dirty bits
int dirtyBitsPosition = writer.Position;
// Reserve the space for the bits
writer.Write(dirtyBits);
for (int i = 0; i < parameters.Length; i++)
{
if (autoSend && !GetParameterAutoSend(i))
@ -208,18 +219,44 @@ void WriteParameters(NetworkWriter writer, bool autoSend)
AnimatorControllerParameter par = parameters[i];
if (par.type == AnimatorControllerParameterType.Int)
{
writer.WritePackedUInt32((uint)m_Animator.GetInteger(par.nameHash));
int newIntValue = m_Animator.GetInteger(par.nameHash);
if (newIntValue != lastIntParameters[i])
{
writer.WritePackedUInt32((uint) newIntValue);
dirtyBits |= 1u << i;
lastIntParameters[i] = newIntValue;
}
}
else if (par.type == AnimatorControllerParameterType.Float)
{
writer.Write(m_Animator.GetFloat(par.nameHash));
float newFloatValue = m_Animator.GetFloat(par.nameHash);
if (Mathf.Abs(newFloatValue - lastFloatParameters[i]) > 0.001f)
{
writer.Write(newFloatValue);
dirtyBits |= 1u << i;
lastFloatParameters[i] = newFloatValue;
}
}
else if (par.type == AnimatorControllerParameterType.Bool)
{
writer.Write(m_Animator.GetBool(par.nameHash));
bool newBoolValue = m_Animator.GetBool(par.nameHash);
if (newBoolValue != lastBoolParameters[i])
{
writer.Write(newBoolValue);
dirtyBits |= 1u << i;
lastBoolParameters[i] = newBoolValue;
}
}
}
// Save the position we were at to return to after writing dirtyBits
int messageEndPosition = writer.Position;
// Write the dirty bits into the reserved position
writer.Position = dirtyBitsPosition;
writer.Write(dirtyBits);
// Return to the end position, so that serialization includes parameter data.
writer.Position = messageEndPosition;
return dirtyBits != 0;
}
void ReadParameters(NetworkReader reader, bool autoSend)
{
@ -227,16 +264,19 @@ void ReadParameters(NetworkReader reader, bool autoSend)
// a new parameter array every time it is accessed so we should avoid doing it in a loop
AnimatorControllerParameter[] parameters = m_Animator.parameters;
uint dirtyBits = reader.ReadUInt32();
for (int i = 0; i < parameters.Length; i++)
{
if (autoSend && !GetParameterAutoSend(i))
continue;
if ((dirtyBits & (1 << i)) == 0)
continue;
AnimatorControllerParameter par = parameters[i];
if (par.type == AnimatorControllerParameterType.Int)
{
int newValue = (int)reader.ReadPackedUInt32();
m_Animator.SetInteger(par.nameHash, newValue);
int newIntValue = (int)reader.ReadPackedUInt32();
m_Animator.SetInteger(par.nameHash, newIntValue);
}
else if (par.type == AnimatorControllerParameterType.Float)
{
@ -293,7 +333,7 @@ public void SetTrigger(int hash)
{
if (hasAuthority && localPlayerAuthority)
{
if (NetworkClient.allClients.Count > 0 && ClientScene.readyConnection != null)
if (NetworkClient.singleton != null && ClientScene.readyConnection != null)
{
CmdOnAnimationTriggerServerMessage(hash);
}
@ -306,12 +346,11 @@ public void SetTrigger(int hash)
}
}
// ------------------ server message handlers -------------------
#region server message handlers
[Command]
void CmdOnAnimationServerMessage(int stateHash, float normalizedTime, byte[] parameters)
{
if (LogFilter.Debug) { Debug.Log("OnAnimationMessage for netId=" + netId); }
if (LogFilter.Debug) Debug.Log("OnAnimationMessage for netId=" + netId);
// handle and broadcast
HandleAnimMsg(stateHash, normalizedTime, new NetworkReader(parameters));
@ -333,8 +372,9 @@ void CmdOnAnimationTriggerServerMessage(int hash)
HandleAnimTriggerMsg(hash);
RpcOnAnimationTriggerClientMessage(hash);
}
#endregion
// ------------------ client message handlers -------------------
#region client message handlers
[ClientRpc]
void RpcOnAnimationClientMessage(int stateHash, float normalizedTime, byte[] parameters)
{
@ -353,5 +393,6 @@ void RpcOnAnimationTriggerClientMessage(int hash)
{
HandleAnimTriggerMsg(hash);
}
#endregion
}
}

View File

@ -10,7 +10,7 @@ namespace Mirror
[HelpURL("https://vis2k.github.io/Mirror/Components/NetworkLobbyManager")]
public class NetworkLobbyManager : NetworkManager
{
struct PendingPlayer
public struct PendingPlayer
{
public NetworkConnection conn;
public GameObject lobbyPlayer;
@ -29,8 +29,8 @@ struct PendingPlayer
public string GameplayScene;
// runtime data
[FormerlySerializedAs("m_PendingPlayers")] List<PendingPlayer> pendingPlayers = new List<PendingPlayer>();
List<NetworkLobbyPlayer> lobbySlots = new List<NetworkLobbyPlayer>();
[FormerlySerializedAs("m_PendingPlayers")] public List<PendingPlayer> pendingPlayers = new List<PendingPlayer>();
public List<NetworkLobbyPlayer> lobbySlots = new List<NetworkLobbyPlayer>();
public bool allPlayersReady;
@ -195,7 +195,13 @@ public override void OnServerDisconnect(NetworkConnection conn)
OnLobbyServerDisconnect(conn);
}
[System.Obsolete("Use OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage) instead")]
public override void OnServerAddPlayer(NetworkConnection conn)
{
OnServerAddPlayer(conn, null);
}
public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
{
if (SceneManager.GetActiveScene().name != LobbyScene) return;
@ -203,7 +209,7 @@ public override void OnServerAddPlayer(NetworkConnection conn)
allPlayersReady = false;
if (LogFilter.Debug) Debug.LogFormat("NetworkLobbyManager:OnServerAddPlayer playerPrefab:{0}", lobbyPlayerPrefab.name);
if (LogFilter.Debug) Debug.LogFormat("NetworkLobbyManager.OnServerAddPlayer playerPrefab:{0}", lobbyPlayerPrefab.name);
GameObject newLobbyGameObject = OnLobbyServerCreateLobbyPlayer(conn);
if (newLobbyGameObject == null)

View File

@ -1,4 +1,3 @@
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
@ -88,7 +87,7 @@ public virtual void OnGUI()
GUILayout.BeginArea(new Rect(20f + (Index * 100), 200f, 90f, 130f));
GUILayout.Label(String.Format("Player [{0}]", Index + 1));
GUILayout.Label($"Player [{Index + 1}]");
if (ReadyToBegin)
GUILayout.Label("Ready");

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEngine;
@ -20,7 +19,7 @@ public enum CheckMethod
// how often to refresh the list of observers, in seconds
[Tooltip("How often (in seconds) that this object should update the set of players that can see it.")]
public float visUpdateInterval = 1.0f;
public float visUpdateInterval = 1;
[Tooltip("Which method to use for checking proximity of players.\n\nPhysics3D uses 3D physics to determine proximity.\n\nPhysics2D uses 2D physics to determine proximity.")]
public CheckMethod checkMethod = CheckMethod.Physics3D;
@ -34,6 +33,14 @@ public enum CheckMethod
float m_VisUpdateTime;
// OverlapSphereNonAlloc array to avoid allocations.
// -> static so we don't create one per component
// -> this is worth it because proximity checking happens for just about
// every entity on the server!
// -> should be big enough to work in just about all cases
static Collider[] hitsBuffer3D = new Collider[10000];
static Collider2D[] hitsBuffer2D = new Collider2D[10000];
void Update()
{
if (!NetworkServer.active)
@ -78,10 +85,13 @@ public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bo
{
case CheckMethod.Physics3D:
{
Collider[] hits = Physics.OverlapSphere(transform.position, visRange, castLayers);
for (int i = 0; i < hits.Length; i++)
// cast without allocating GC for maximum performance
int hitCount = Physics.OverlapSphereNonAlloc(transform.position, visRange, hitsBuffer3D, castLayers);
if (hitCount == hitsBuffer3D.Length) Debug.LogWarning("NetworkProximityChecker's OverlapSphere test for " + name + " has filled the whole buffer(" + hitsBuffer3D.Length + "). Some results might have been omitted. Consider increasing buffer size.");
for (int i = 0; i < hitCount; i++)
{
Collider hit = hits[i];
Collider hit = hitsBuffer3D[i];
// collider might be on pelvis, often the NetworkIdentity is in a parent
// (looks in the object itself and then parents)
NetworkIdentity identity = hit.GetComponentInParent<NetworkIdentity>();
@ -96,10 +106,13 @@ public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bo
case CheckMethod.Physics2D:
{
Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, visRange, castLayers);
for (int i = 0; i < hits.Length; i++)
// cast without allocating GC for maximum performance
int hitCount = Physics2D.OverlapCircleNonAlloc(transform.position, visRange, hitsBuffer2D, castLayers);
if (hitCount == hitsBuffer2D.Length) Debug.LogWarning("NetworkProximityChecker's OverlapCircle test for " + name + " has filled the whole buffer(" + hitsBuffer2D.Length + "). Some results might have been omitted. Consider increasing buffer size.");
for (int i = 0; i < hitCount; i++)
{
Collider2D hit = hits[i];
Collider2D hit = hitsBuffer2D[i];
// collider might be on pelvis, often the NetworkIdentity is in a parent
// (looks in the object itself and then parents)
NetworkIdentity identity = hit.GetComponentInParent<NetworkIdentity>();

View File

@ -16,7 +16,6 @@
// * Only way for smooth movement is to use a fixed movement speed during
// interpolation. interpolation over time is never that good.
//
using System;
using UnityEngine;
namespace Mirror
@ -29,7 +28,7 @@ public abstract class NetworkTransformBase : NetworkBehaviour
// to save bandwidth in the first place.
// -> can still be modified in the Inspector while the game is running,
// but would cause errors immediately and be pretty obvious.
[Tooltip("Compresses 16 Byte Quaternion into None=12, Some=6, Much=3, Lots=2 Byte")]
[Tooltip("Compresses 16 Byte Quaternion into None=12, Much=3, Lots=2 Byte")]
[SerializeField] Compression compressRotation = Compression.Much;
public enum Compression { None, Much, Lots }; // easily understandable and funny
@ -77,14 +76,14 @@ static void SerializeIntoWriter(NetworkWriter writer, Vector3 position, Quaterni
else if (compressRotation == Compression.Much)
{
// write 3 byte. scaling [0,360] to [0,255]
writer.Write(Utils.ScaleFloatToByte(euler.x, 0, 360, byte.MinValue, byte.MaxValue));
writer.Write(Utils.ScaleFloatToByte(euler.y, 0, 360, byte.MinValue, byte.MaxValue));
writer.Write(Utils.ScaleFloatToByte(euler.z, 0, 360, byte.MinValue, byte.MaxValue));
writer.Write(FloatBytePacker.ScaleFloatToByte(euler.x, 0, 360, byte.MinValue, byte.MaxValue));
writer.Write(FloatBytePacker.ScaleFloatToByte(euler.y, 0, 360, byte.MinValue, byte.MaxValue));
writer.Write(FloatBytePacker.ScaleFloatToByte(euler.z, 0, 360, byte.MinValue, byte.MaxValue));
}
else if (compressRotation == Compression.Lots)
{
// write 2 byte, 5 bits for each float
writer.Write(Utils.PackThreeFloatsIntoUShort(euler.x, euler.y, euler.z, 0, 360));
writer.Write(FloatBytePacker.PackThreeFloatsIntoUShort(euler.x, euler.y, euler.z, 0, 360));
}
}
@ -128,19 +127,18 @@ void DeserializeFromReader(NetworkReader reader)
else if (compressRotation == Compression.Much)
{
// read 3 byte. scaling [0,255] to [0,360]
float x = Utils.ScaleByteToFloat(reader.ReadByte(), byte.MinValue, byte.MaxValue, 0, 360);
float y = Utils.ScaleByteToFloat(reader.ReadByte(), byte.MinValue, byte.MaxValue, 0, 360);
float z = Utils.ScaleByteToFloat(reader.ReadByte(), byte.MinValue, byte.MaxValue, 0, 360);
float x = FloatBytePacker.ScaleByteToFloat(reader.ReadByte(), byte.MinValue, byte.MaxValue, 0, 360);
float y = FloatBytePacker.ScaleByteToFloat(reader.ReadByte(), byte.MinValue, byte.MaxValue, 0, 360);
float z = FloatBytePacker.ScaleByteToFloat(reader.ReadByte(), byte.MinValue, byte.MaxValue, 0, 360);
temp.rotation = Quaternion.Euler(x, y, z);
}
else if (compressRotation == Compression.Lots)
{
// read 2 byte, 5 bits per float
float[] xyz = Utils.UnpackUShortIntoThreeFloats(reader.ReadUInt16(), 0, 360);
float[] xyz = FloatBytePacker.UnpackUShortIntoThreeFloats(reader.ReadUInt16(), 0, 360);
temp.rotation = Quaternion.Euler(xyz[0], xyz[1], xyz[2]);
}
// timestamp
temp.timeStamp = Time.time;
// movement speed: based on how far it moved since last time
@ -298,10 +296,16 @@ bool HasMovedOrRotated()
bool rotated = lastRotation != targetComponent.transform.rotation;
// save last for next frame to compare
// (only if change was detected. otherwise slow moving objects might
// never sync because of C#'s float comparison tolerance. see also:
// https://github.com/vis2k/Mirror/pull/428)
bool change = moved || rotated;
if (change)
{
lastPosition = targetComponent.transform.position;
lastRotation = targetComponent.transform.rotation;
return moved || rotated;
}
return change;
}
// set position carefully depending on the target component

View File

@ -13,7 +13,7 @@ public class NetworkAnimatorEditor : Editor
[NonSerialized] bool m_Initialized;
SerializedProperty m_AnimatorProperty;
GUIContent m_AnimatorLabel;
GUIContent m_AnimatorLabel = new GUIContent("Animator", "The Animator component to synchronize.");
void Init()
{
@ -24,7 +24,6 @@ void Init()
m_AnimSync = target as NetworkAnimator;
m_AnimatorProperty = serializedObject.FindProperty("m_Animator");
m_AnimatorLabel = new GUIContent("Animator", "The Animator component to synchronize.");
}
public override void OnInspectorGUI()
@ -63,7 +62,7 @@ void DrawControls()
}
bool oldSend = m_AnimSync.GetParameterAutoSend(i);
bool send = EditorGUILayout.Toggle(p.name, oldSend);
bool send = EditorGUILayout.Toggle("Sync " + p.name, oldSend);
if (send != oldSend)
{
m_AnimSync.SetParameterAutoSend(i, send);

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@ -12,9 +11,9 @@ public class NetworkIdentityEditor : Editor
SerializedProperty m_ServerOnlyProperty;
SerializedProperty m_LocalPlayerAuthorityProperty;
GUIContent m_ServerOnlyLabel;
GUIContent m_LocalPlayerAuthorityLabel;
GUIContent m_SpawnLabel;
GUIContent m_ServerOnlyLabel = new GUIContent("Server Only", "True if the object should only exist on the server.");
GUIContent m_LocalPlayerAuthorityLabel = new GUIContent("Local Player Authority", "True if this object will be controlled by a player on a client.");
GUIContent m_SpawnLabel = new GUIContent("Spawn Object", "This causes an unspawned server object to be spawned on clients");
NetworkIdentity m_NetworkIdentity;
bool m_Initialized;
@ -31,10 +30,6 @@ void Init()
m_ServerOnlyProperty = serializedObject.FindProperty("m_ServerOnly");
m_LocalPlayerAuthorityProperty = serializedObject.FindProperty("m_LocalPlayerAuthority");
m_ServerOnlyLabel = new GUIContent("Server Only", "True if the object should only exist on the server.");
m_LocalPlayerAuthorityLabel = new GUIContent("Local Player Authority", "True if this object will be controlled by a player on a client.");
m_SpawnLabel = new GUIContent("Spawn Object", "This causes an unspawned server object to be spawned on clients");
}
public override void OnInspectorGUI()

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
@ -216,7 +215,7 @@ void GetNetworkInformation(GameObject gameObject)
m_Info = new List<NetworkIdentityInfo>
{
GetAssetId(),
GetString("Scene ID", m_Identity.sceneId.ToString())
GetString("Scene ID", m_Identity.sceneId.ToString("X"))
};
if (!Application.isPlaying)

View File

@ -1,10 +1,6 @@
using System;
using System.IO;
using System.Reflection;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using UnityObject = UnityEngine.Object;
namespace Mirror
{

View File

@ -1,5 +1,3 @@
using System.Text;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.Callbacks;
@ -10,168 +8,20 @@ namespace Mirror
{
public class NetworkScenePostProcess : MonoBehaviour
{
// persistent sceneId assignment to fix readstring bug that occurs when restarting the editor and
// connecting to a build again. sceneids were then different because FindObjectsOfType's order
// is not guranteed to be the same.
// -> we need something unique and persistent, aka always the same when pressing play/building the first time
// -> Unity has no built in unique id for GameObjects in the scene
// helper function to figure out a unique, persistent scene id for a GameObject in the hierarchy
// -> Unity's instanceId is unique but not persistent
// -> hashing the whole GameObject is not enough either since a duplicate would have the same hash
// -> we definitely need the transform sibling index in the hierarchy
// -> so we might as well use just that
// -> transforms have children too so we need a list of sibling indices like 0->3->5
public static List<int> SiblingPathFor(Transform t)
{
List<int> result = new List<int>();
while (t != null)
{
result.Add(t.GetSiblingIndex());
t = t.parent;
}
result.Reverse(); // parent to child instead of child to parent order
return result;
}
// we need to compare by using the whole sibling list
// comparing the string won't work work because:
// "1->2"
// "20->2"
// would compare '1' vs '2', then '-' vs '0'
//
// tests:
// CompareSiblingPaths(new List<int>(){0}, new List<int>(){0}) => 0
// CompareSiblingPaths(new List<int>(){0}, new List<int>(){1}) => -1
// CompareSiblingPaths(new List<int>(){1}, new List<int>(){0}) => 1
// CompareSiblingPaths(new List<int>(){0,1}, new List<int>(){0,2}) => -1
// CompareSiblingPaths(new List<int>(){0,2}, new List<int>(){0,1}) => 1
// CompareSiblingPaths(new List<int>(){1}, new List<int>(){0,1}) => 1
// CompareSiblingPaths(new List<int>(){1}, new List<int>(){2,1}) => -1
public static int CompareSiblingPaths(List<int> left, List<int> right)
{
// compare [0], remove it, compare next, etc.
while (left.Count > 0 && right.Count > 0)
{
if (left[0] < right[0])
{
return -1;
}
else if (left[0] > right[0])
{
return 1;
}
else
{
// equal, so they are both children of the same transform
// -> which also means that they both must have one more
// entry, so we can remove both without checking size
left.RemoveAt(0);
right.RemoveAt(0);
}
}
// equal if both were empty or both had the same entry without any
// more children (should never happen in practice)
return 0;
}
public static int CompareNetworkIdentitySiblingPaths(NetworkIdentity left, NetworkIdentity right)
{
return CompareSiblingPaths(SiblingPathFor(left.transform), SiblingPathFor(right.transform));
}
// we might have inactive scenes in the Editor's build settings, which
// aren't actually included in builds.
// so we have to only count the active ones when in Editor, otherwise
// editor and build sceneIds might get out of sync.
public static int GetSceneCount()
{
#if UNITY_EDITOR
return EditorBuildSettings.scenes.Count(scene => scene.enabled);
#else
return SceneManager.sceneCountInBuildSettings;
#endif
}
// helper function to check if a NetworkIdentity is in the active scene
static bool InActiveScene(NetworkIdentity identity) =>
identity.gameObject.scene == SceneManager.GetActiveScene();
[PostProcessScene]
public static void OnPostProcessScene()
{
// vis2k: MISMATCHING SCENEID BUG FIX
// problem:
// * FindObjectsOfType order is not guaranteed. restarting the
// editor results in a different order
// * connecting to a build again would cause UNET to deserialize
// the wrong objects, causing all kinds of weird errors like
// 'ReadString out of range'
//
// solution:
// sort by sibling-index path, e.g. [0,1,2] vs [1]
// this is the only deterministic way to sort a list of objects in
// the scene.
// -> it's the same result every single time, even after restarts
//
// note: there is a reason why we 'sort by' sibling path instead of
// using it as sceneId directly. networkmanager etc. use Dont-
// DestroyOnLoad, which changes the hierarchy:
//
// World:
// NetworkManager
// Player
//
// ..becomes..
//
// World:
// Player
// DontDestroyOnLoad:
// NetworkManager
//
// so the player's siblingindex would be decreased by one.
// -> this is a problem because when building, OnPostProcessScene
// is called before any dontdestroyonload happens, but when
// entering play mode, it's called after
// -> hence sceneids would differ by one
//
// => but if we only SORT it, then it doesn't matter if one
// inbetween disappeared. as long as no NetworkIdentity used
// DontDestroyOnLoad.
//
// note: assigning a GUID in NetworkIdentity.OnValidate would be way
// cooler, but OnValidate isn't called for other unopened scenes
// when building or pressing play, so the bug would still happen
// there.
//
// note: this can still fail if DontDestroyOnLoad is called for a
// NetworkIdentity - but no one should ever do that anyway.
List<NetworkIdentity> identities = FindObjectsOfType<NetworkIdentity>().ToList();
identities.Sort(CompareNetworkIdentitySiblingPaths);
// sceneId assignments need to work with additive scene loading, so
// it can't always start at 1,2,3,4,..., otherwise there will be
// sceneId duplicates.
// -> we need an offset to start at 1000+1,+2,+3, etc.
// -> the most robust way is to split uint value range by sceneCount
// -> only if more than one scene. otherwise use offset 0 to avoid
// DivisionByZero if no scene in build settings, and to avoid
// different offsets in editor/build if scene wasn't added to
// build settings.
uint offsetPerScene = 0;
if (SceneManager.sceneCountInBuildSettings > 1)
{
offsetPerScene = uint.MaxValue / (uint)GetSceneCount();
// make sure that there aren't more sceneIds than offsetPerScene
// -> only if we have multiple scenes. otherwise offset is 0, in
// which case it doesn't matter.
if (identities.Count >= offsetPerScene)
{
Debug.LogWarning(">=" + offsetPerScene + " NetworkIdentities in scene. Additive scene loading will cause duplicate ids.");
}
}
uint nextSceneId = 1;
foreach (NetworkIdentity identity in identities)
// find all NetworkIdentities in this scene
// => but really only from this scene. this avoids weird situations
// like in NetworkZones when we destroy the local player and
// load another scene afterwards, yet the local player is still
// in the FindObjectsOfType result with scene=DontDestroyOnLoad
// for some reason
foreach (NetworkIdentity identity in FindObjectsOfType<NetworkIdentity>().Where(InActiveScene))
{
// if we had a [ConflictComponent] attribute that would be better than this check.
// also there is no context about which scene this is in.
@ -182,12 +32,21 @@ public static void OnPostProcessScene()
if (identity.isClient || identity.isServer)
continue;
uint offset = (uint)identity.gameObject.scene.buildIndex * offsetPerScene;
identity.ForceSceneId(offset + nextSceneId++);
if (LogFilter.Debug) { Debug.Log("PostProcess sceneid assigned: name=" + identity.name + " scene=" + identity.gameObject.scene.name + " sceneid=" + identity.sceneId); }
// valid scene id? then set scene path part
// otherwise it might be an unopened scene that still has null
// sceneIds. builds are interrupted if they contain 0 sceneIds,
// but it's still possible that we call LoadScene in Editor
// for a previously unopened scene.
// => throwing an exception would only show it for one object
// because this function would return afterwards.
if (identity.sceneId != 0)
{
identity.SetSceneIdSceneHashPartInternal();
}
else Debug.LogError("Scene " + identity.gameObject.scene.path + " needs to be opened and resaved, because the scene object " + identity.name + " has no valid sceneId yet.");
// disable it AFTER assigning the sceneId.
// -> this way NetworkIdentity.OnDisable adds itself to the
// disable it
// note: NetworkIdentity.OnDisable adds itself to the
// spawnableObjects dictionary (only if sceneId != 0)
identity.gameObject.SetActive(false);

View File

@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Mirror
{

View File

@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;
using UnityEngine;
namespace Mirror

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: cad1d2d7f70fb4e509408b6733c359d2
guid: d9f8e6274119b4ce29e498cfb8aca8a4
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -0,0 +1,201 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
using Assembly = System.Reflection.Assembly;
namespace Mirror.Weaver
{
public class CompilationFinishedHook
{
const string MirrorRuntimeAssemblyName = "Mirror";
const string MirrorWeaverAssemblyName = "Mirror.Weaver";
public static Action<string> OnWeaverMessage; // delegate for subscription to Weaver debug messages
public static Action<string> OnWeaverWarning; // delegate for subscription to Weaver warning messages
public static Action<string> OnWeaverError; // delete for subscription to Weaver error messages
public static bool WeaverEnabled { get; set; } // controls whether we weave any assemblies when CompilationPipeline delegates are invoked
public static bool UnityLogEnabled = true; // controls weather Weaver errors are reported direct to the Unity console (tests enable this)
public static bool WeaveFailed { get; private set; } // holds the result status of our latest Weave operation
// debug message handler that also calls OnMessageMethod delegate
static void HandleMessage(string msg)
{
if (UnityLogEnabled) Debug.Log(msg);
if (OnWeaverMessage != null) OnWeaverMessage.Invoke(msg);
}
// warning message handler that also calls OnWarningMethod delegate
static void HandleWarning(string msg)
{
if (UnityLogEnabled) Debug.LogWarning(msg);
if (OnWeaverWarning != null) OnWeaverWarning.Invoke(msg);
}
// error message handler that also calls OnErrorMethod delegate
static void HandleError(string msg)
{
if (UnityLogEnabled) Debug.LogError(msg);
if (OnWeaverError != null) OnWeaverError.Invoke(msg);
}
[InitializeOnLoadMethod]
static void OnInitializeOnLoad()
{
CompilationPipeline.assemblyCompilationFinished += OnCompilationFinished;
}
static string FindMirrorRuntime()
{
UnityEditor.Compilation.Assembly[] assemblies = CompilationPipeline.GetAssemblies();
foreach (UnityEditor.Compilation.Assembly assembly in assemblies)
{
if (assembly.name == MirrorRuntimeAssemblyName)
{
return assembly.outputPath;
}
}
return "";
}
// get all dependency directories
static HashSet<string> GetDependencyDirectories(AssemblyName[] dependencies)
{
// Since this assembly is already loaded in the domain this is a
// no-op and returns the already loaded assembly
return new HashSet<string>(
dependencies.Select(dependency => Path.GetDirectoryName(Assembly.Load(dependency).Location))
);
}
// get all non-dynamic assembly directories
static HashSet<string> GetNonDynamicAssemblyDirectories(Assembly[] assemblies)
{
HashSet<string> paths = new HashSet<string>();
foreach (Assembly assembly in assemblies)
{
if (!assembly.IsDynamic)
{
// need to check if file exists to avoid potential
// FileNotFoundException in Assembly.Load
string assemblyName = assembly.GetName().Name;
if (File.Exists(assemblyName))
{
paths.Add(Path.GetDirectoryName(Assembly.Load(assemblyName).Location));
}
}
}
return paths;
}
static bool CompilerMessagesContainError(CompilerMessage[] messages)
{
return messages.Any(msg => msg.type == CompilerMessageType.Error);
}
static void OnCompilationFinished(string assemblyPath, CompilerMessage[] messages)
{
// Do nothing if there were compile errors on the target
if (CompilerMessagesContainError(messages))
{
Debug.Log("Weaver: stop because compile errors on target");
return;
}
// Should not run on the editor only assemblies
if (assemblyPath.Contains("-Editor") || assemblyPath.Contains(".Editor"))
{
return;
}
// don't weave mirror files
string assemblyName = Path.GetFileNameWithoutExtension(assemblyPath);
if (assemblyName == MirrorRuntimeAssemblyName || assemblyName == MirrorWeaverAssemblyName)
{
return;
}
// find Mirror.dll
string mirrorRuntimeDll = FindMirrorRuntime();
if (string.IsNullOrEmpty(mirrorRuntimeDll))
{
Debug.LogError("Failed to find Mirror runtime assembly");
return;
}
if (!File.Exists(mirrorRuntimeDll))
{
// this is normal, it happens with any assembly that is built before mirror
// such as unity packages or your own assemblies
// those don't need to be weaved
// if any assembly depends on mirror, then it will be built after
return;
}
// find UnityEngine.CoreModule.dll
string unityEngineCoreModuleDLL = UnityEditorInternal.InternalEditorUtility.GetEngineCoreModuleAssemblyPath();
if (string.IsNullOrEmpty(unityEngineCoreModuleDLL))
{
Debug.LogError("Failed to find UnityEngine assembly");
return;
}
// find all assemblies and the currently compiling assembly
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
Assembly targetAssembly = assemblies.FirstOrDefault(asm => asm.GetName().Name == Path.GetFileNameWithoutExtension(assemblyPath));
// prepare variables
HashSet<string> dependencyPaths = new HashSet<string>();
// found this assembly in assemblies?
if (targetAssembly != null)
{
// get all dependencies for the target assembly
AssemblyName[] dependencies = targetAssembly.GetReferencedAssemblies();
// does the target assembly depend on Mirror at all?
// otherwise there is nothing to weave anyway.
bool usesMirror = dependencies.Any(dependency => dependency.Name == MirrorRuntimeAssemblyName);
if (!usesMirror)
{
return;
}
// get all the directories
dependencyPaths = GetDependencyDirectories(dependencies);
}
else
{
// Target assembly not found in current domain, trying to load it to check references
// will lead to trouble in the build pipeline, so lets assume it should go to weaver.
// Add all assemblies in current domain to dependency list since there could be a
// dependency lurking there (there might be generated assemblies so ignore file not found exceptions).
// (can happen in runtime test framework on editor platform and when doing full library reimport)
dependencyPaths = GetNonDynamicAssemblyDirectories(assemblies);
}
// construct full path to Project/Library/ScriptAssemblies
string projectDirectory = Directory.GetParent(Application.dataPath).ToString();
string outputDirectory = Path.Combine(projectDirectory, Path.GetDirectoryName(assemblyPath));
//if (UnityLogEnabled) Debug.Log("Weaving: " + assemblyPath); // uncomment to easily observe weave targets
if (Program.Process(unityEngineCoreModuleDLL, mirrorRuntimeDll, outputDirectory, new[] { assemblyPath }, dependencyPaths.ToArray(), HandleWarning, HandleError))
{
WeaveFailed = false;
Debug.Log("Weaving succeeded for: " + assemblyPath);
}
else
{
WeaveFailed = true;
if (UnityLogEnabled) Debug.LogError("Weaving failed for: " + assemblyPath);
}
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c764a8a81af7e41539c3cdc06aa036be
guid: de2aeb2e8068f421a9a1febe408f7051
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

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

View File

@ -85,16 +85,16 @@ public static string PrettyPrintType(TypeReference type)
return type.Name;
}
public static ReaderParameters ReaderParameters(string assemblyPath, IEnumerable<string> extraPaths, IAssemblyResolver assemblyResolver, string unityEngineDLLPath, string unityUNetDLLPath)
public static ReaderParameters ReaderParameters(string assemblyPath, IEnumerable<string> extraPaths, IAssemblyResolver assemblyResolver, string unityEngineDLLPath, string mirrorNetDLLPath)
{
ReaderParameters parameters = new ReaderParameters();
ReaderParameters parameters = new ReaderParameters() {ReadWrite = true};
if (assemblyResolver == null)
assemblyResolver = new DefaultAssemblyResolver();
AddSearchDirectoryHelper helper = new AddSearchDirectoryHelper(assemblyResolver);
helper.AddSearchDirectory(Path.GetDirectoryName(assemblyPath));
helper.AddSearchDirectory(UnityEngineDLLDirectoryName());
helper.AddSearchDirectory(Path.GetDirectoryName(unityEngineDLLPath));
helper.AddSearchDirectory(Path.GetDirectoryName(unityUNetDLLPath));
helper.AddSearchDirectory(Path.GetDirectoryName(mirrorNetDLLPath));
if (extraPaths != null)
{
foreach (var path in extraPaths)

View File

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

View File

@ -0,0 +1,14 @@
{
"name": "Mirror.Weaver",
"references": [],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5710c1f859f1945b6bc9b33cff6b43fc
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e538d627280d2471b8c72fdea822ca49
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -12,13 +12,6 @@ public static class CommandProcessor
// generates code like:
public void CallCmdThrust(float thrusting, int spin)
{
Debug.LogError("Call Command function CmdThrust");
if (!NetworkClient.active)
{
Debug.LogError("Command function CmdThrust called on server.");
return;
}
if (isServer)
{
// we are ON the server, invoke directly
@ -49,14 +42,12 @@ public static MethodDefinition ProcessCommandCall(TypeDefinition td, MethodDefin
NetworkBehaviourProcessor.WriteSetupLocals(cmdWorker);
if (Weaver.generateLogErrors)
if (Weaver.GenerateLogErrors)
{
cmdWorker.Append(cmdWorker.Create(OpCodes.Ldstr, "Call Command function " + md.Name));
cmdWorker.Append(cmdWorker.Create(OpCodes.Call, Weaver.logErrorReference));
}
NetworkBehaviourProcessor.WriteClientActiveCheck(cmdWorker, md.Name, label, "Command function");
// local client check
Instruction localClientLabel = cmdWorker.Create(OpCodes.Nop);
cmdWorker.Append(cmdWorker.Create(OpCodes.Ldarg_0));
@ -143,15 +134,13 @@ public static bool ProcessMethodsValidateCommand(TypeDefinition td, MethodDefini
{
if (md.Name.Length > 2 && md.Name.Substring(0, 3) != "Cmd")
{
Log.Error("Command function [" + td.FullName + ":" + md.Name + "] doesnt have 'Cmd' prefix");
Weaver.fail = true;
Weaver.Error("Command function [" + td.FullName + ":" + md.Name + "] doesnt have 'Cmd' prefix");
return false;
}
if (md.IsStatic)
{
Log.Error("Command function [" + td.FullName + ":" + md.Name + "] cant be a static method");
Weaver.fail = true;
Weaver.Error("Command function [" + td.FullName + ":" + md.Name + "] cant be a static method");
return false;
}

View File

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

View File

@ -13,7 +13,7 @@ public static void Process(TypeDefinition td)
Weaver.ResetRecursionCount();
GenerateSerialization(td);
if (Weaver.fail)
if (Weaver.WeavingFailed)
{
return;
}
@ -41,8 +41,7 @@ static void GenerateSerialization(TypeDefinition td)
{
if (field.FieldType.FullName == td.FullName)
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " [" + field.FullName + "]. [MessageBase] member cannot be self referencing.");
Weaver.Error("GenerateSerialization for " + td.Name + " [" + field.FullName + "]. [MessageBase] member cannot be self referencing.");
return;
}
}
@ -51,7 +50,7 @@ static void GenerateSerialization(TypeDefinition td)
MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
Weaver.voidType);
serializeFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkWriterType)));
serializeFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkWriterType)));
ILProcessor serWorker = serializeFunc.Body.GetILProcessor();
foreach (FieldDefinition field in td.Fields)
@ -61,15 +60,13 @@ static void GenerateSerialization(TypeDefinition td)
if (field.FieldType.Resolve().HasGenericParameters)
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. [MessageBase] member cannot have generic parameters.");
Weaver.Error("GenerateSerialization for " + td.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. [MessageBase] member cannot have generic parameters.");
return;
}
if (field.FieldType.Resolve().IsInterface)
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. [MessageBase] member cannot be an interface.");
Weaver.Error("GenerateSerialization for " + td.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. [MessageBase] member cannot be an interface.");
return;
}
@ -83,8 +80,7 @@ static void GenerateSerialization(TypeDefinition td)
}
else
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " unknown type [" + field.FieldType + "/" + field.FieldType.FullName + "]. [MessageBase] member variables must be basic types.");
Weaver.Error("GenerateSerialization for " + td.Name + " unknown type [" + field.FieldType + "/" + field.FieldType.FullName + "]. [MessageBase] member variables must be basic types.");
return;
}
}
@ -111,7 +107,7 @@ static void GenerateDeSerialization(TypeDefinition td)
MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
Weaver.voidType);
serializeFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkReaderType)));
serializeFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkReaderType)));
ILProcessor serWorker = serializeFunc.Body.GetILProcessor();
foreach (FieldDefinition field in td.Fields)
@ -129,8 +125,7 @@ static void GenerateDeSerialization(TypeDefinition td)
}
else
{
Weaver.fail = true;
Log.Error("GenerateDeSerialization for " + td.Name + " unknown type [" + field.FieldType + "]. [SyncVar] member variables must be basic types.");
Weaver.Error("GenerateDeSerialization for " + td.Name + " unknown type [" + field.FieldType + "]. [SyncVar] member variables must be basic types.");
return;
}
}

View File

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

View File

@ -20,15 +20,13 @@ static void ProcessSyncVars(TypeDefinition td)
{
if (ca.AttributeType.FullName == Weaver.SyncVarType.FullName)
{
Log.Error("Script " + td.FullName + " uses [SyncVar] " + fd.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses [SyncVar] " + fd.Name + " but is not a NetworkBehaviour.");
}
}
if (SyncObjectProcessor.ImplementsSyncObject(fd.FieldType))
if (SyncObjectInitializer.ImplementsSyncObject(fd.FieldType))
{
Log.Error(string.Format("Script {0} defines field {1} with type {2}, but it's not a NetworkBehaviour", td.FullName, fd.Name, Helpers.PrettyPrintType(fd.FieldType)));
Weaver.fail = true;
Weaver.Error(string.Format("Script {0} defines field {1} with type {2}, but it's not a NetworkBehaviour", td.FullName, fd.Name, Helpers.PrettyPrintType(fd.FieldType)));
}
}
}
@ -42,20 +40,17 @@ static void ProcessMethods(TypeDefinition td)
{
if (ca.AttributeType.FullName == Weaver.CommandType.FullName)
{
Log.Error("Script " + td.FullName + " uses [Command] " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses [Command] " + md.Name + " but is not a NetworkBehaviour.");
}
if (ca.AttributeType.FullName == Weaver.ClientRpcType.FullName)
{
Log.Error("Script " + td.FullName + " uses [ClientRpc] " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses [ClientRpc] " + md.Name + " but is not a NetworkBehaviour.");
}
if (ca.AttributeType.FullName == Weaver.TargetRpcType.FullName)
{
Log.Error("Script " + td.FullName + " uses [TargetRpc] " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses [TargetRpc] " + md.Name + " but is not a NetworkBehaviour.");
}
string attributeName = ca.Constructor.DeclaringType.ToString();
@ -63,20 +58,16 @@ static void ProcessMethods(TypeDefinition td)
switch (attributeName)
{
case "Mirror.ServerAttribute":
Log.Error("Script " + td.FullName + " uses the attribute [Server] on the method " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses the attribute [Server] on the method " + md.Name + " but is not a NetworkBehaviour.");
break;
case "Mirror.ServerCallbackAttribute":
Log.Error("Script " + td.FullName + " uses the attribute [ServerCallback] on the method " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses the attribute [ServerCallback] on the method " + md.Name + " but is not a NetworkBehaviour.");
break;
case "Mirror.ClientAttribute":
Log.Error("Script " + td.FullName + " uses the attribute [Client] on the method " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses the attribute [Client] on the method " + md.Name + " but is not a NetworkBehaviour.");
break;
case "Mirror.ClientCallbackAttribute":
Log.Error("Script " + td.FullName + " uses the attribute [ClientCallback] on the method " + md.Name + " but is not a NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("Script " + td.FullName + " uses the attribute [ClientCallback] on the method " + md.Name + " but is not a NetworkBehaviour.");
break;
}
}

View File

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

View File

@ -37,8 +37,7 @@ public void Process()
{
if (m_td.HasGenericParameters)
{
Weaver.fail = true;
Log.Error("NetworkBehaviour " + m_td.Name + " cannot have generic parameters");
Weaver.Error("NetworkBehaviour " + m_td.Name + " cannot have generic parameters");
return;
}
Weaver.DLog(m_td, "Process Start");
@ -49,7 +48,7 @@ public void Process()
ProcessMethods();
SyncEventProcessor.ProcessEvents(m_td, m_Events, m_EventInvocationFuncs);
if (Weaver.fail)
if (Weaver.WeavingFailed)
{
return;
}
@ -57,7 +56,7 @@ public void Process()
Weaver.ResetRecursionCount();
GenerateSerialization();
if (Weaver.fail)
if (Weaver.WeavingFailed)
{
return;
}
@ -104,7 +103,7 @@ public static void WriteServerActiveCheck(ILProcessor worker, string mdName, Ins
public static void WriteSetupLocals(ILProcessor worker)
{
worker.Body.InitLocals = true;
worker.Body.Variables.Add(new VariableDefinition(Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkWriterType)));
worker.Body.Variables.Add(new VariableDefinition(Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkWriterType)));
}
public static void WriteCreateWriter(ILProcessor worker)
@ -129,8 +128,7 @@ public static bool WriteArguments(ILProcessor worker, MethodDefinition md, strin
MethodReference writeFunc = Weaver.GetWriteFunc(pd.ParameterType);
if (writeFunc == null)
{
Log.Error("WriteArguments for " + md.Name + " type " + pd.ParameterType + " not supported");
Weaver.fail = true;
Weaver.Error("WriteArguments for " + md.Name + " type " + pd.ParameterType + " not supported");
return false;
}
// use built-in writer func on writer object
@ -142,7 +140,7 @@ public static bool WriteArguments(ILProcessor worker, MethodDefinition md, strin
return true;
}
// mark / check type as processed //////////////////////////////////////
#region mark / check type as processed
public const string ProcessedFunctionName = "MirrorProcessed";
// by adding an empty MirrorProcessed() function
@ -161,7 +159,7 @@ public static void MarkAsProcessed(TypeDefinition td)
td.Methods.Add(versionMethod);
}
}
////////////////////////////////////////////////////////////////////////
#endregion
void GenerateConstants()
{
@ -193,8 +191,7 @@ void GenerateConstants()
}
else
{
Log.Error("No cctor for " + m_td.Name);
Weaver.fail = true;
Weaver.Error("No cctor for " + m_td.Name);
return;
}
}
@ -226,8 +223,7 @@ void GenerateConstants()
}
else
{
Weaver.fail = true;
Log.Error("No ctor for " + m_td.Name);
Weaver.Error("No ctor for " + m_td.Name);
return;
}
@ -237,8 +233,7 @@ void GenerateConstants()
if (ctor == null)
{
Weaver.fail = true;
Log.Error("No ctor for " + m_td.Name);
Weaver.Error("No ctor for " + m_td.Name);
return;
}
@ -267,8 +262,8 @@ void GenerateConstants()
foreach (FieldDefinition fd in m_SyncObjects)
{
SyncListProcessor.GenerateSyncListInstanceInitializer(ctorWorker, fd);
SyncObjectProcessor.GenerateSyncObjectInitializer(ctorWorker, fd);
SyncListInitializer.GenerateSyncListInstanceInitializer(ctorWorker, fd);
SyncObjectInitializer.GenerateSyncObjectInitializer(ctorWorker, fd);
}
cctorWorker.Append(cctorWorker.Create(OpCodes.Ret));
@ -320,7 +315,7 @@ void GenerateSerialization()
MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
Weaver.boolType);
serialize.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkWriterType)));
serialize.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkWriterType)));
serialize.Parameters.Add(new ParameterDefinition("forceAll", ParameterAttributes.None, Weaver.boolType));
ILProcessor serWorker = serialize.Body.GetILProcessor();
@ -330,7 +325,7 @@ void GenerateSerialization()
VariableDefinition dirtyLocal = new VariableDefinition(Weaver.boolType);
serialize.Body.Variables.Add(dirtyLocal);
MethodReference baseSerialize = Resolvers.ResolveMethodInParents(m_td.BaseType, Weaver.scriptDef, "OnSerialize");
MethodReference baseSerialize = Resolvers.ResolveMethodInParents(m_td.BaseType, Weaver.CurrentAssembly, "OnSerialize");
if (baseSerialize != null)
{
serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base
@ -358,8 +353,7 @@ void GenerateSerialization()
}
else
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + m_td.Name + " unknown type [" + syncVar.FieldType + "]. UNet [SyncVar] member variables must be basic types.");
Weaver.Error("GenerateSerialization for " + m_td.Name + " unknown type [" + syncVar.FieldType + "]. Mirror [SyncVar] member variables must be basic types.");
return;
}
}
@ -407,8 +401,7 @@ void GenerateSerialization()
}
else
{
Log.Error("GenerateSerialization for " + m_td.Name + " unknown type [" + syncVar.FieldType + "]. UNet [SyncVar] member variables must be basic types.");
Weaver.fail = true;
Weaver.Error("GenerateSerialization for " + m_td.Name + " unknown type [" + syncVar.FieldType + "]. Mirror [SyncVar] member variables must be basic types.");
return;
}
@ -420,7 +413,7 @@ void GenerateSerialization()
dirtyBit += 1;
}
if (Weaver.generateLogErrors)
if (Weaver.GenerateLogErrors)
{
serWorker.Append(serWorker.Create(OpCodes.Ldstr, "Injected Serialize " + m_td.Name));
serWorker.Append(serWorker.Create(OpCodes.Call, Weaver.logErrorReference));
@ -493,8 +486,7 @@ void DeserializeField(FieldDefinition syncVar, ILProcessor serWorker)
MethodReference readFunc = Weaver.GetReadFunc(syncVar.FieldType);
if (readFunc == null)
{
Log.Error("GenerateDeSerialization for " + m_td.Name + " unknown type [" + syncVar.FieldType + "]. UNet [SyncVar] member variables must be basic types.");
Weaver.fail = true;
Weaver.Error("GenerateDeSerialization for " + m_td.Name + " unknown type [" + syncVar.FieldType + "]. Mirror [SyncVar] member variables must be basic types.");
return;
}
@ -538,11 +530,11 @@ void GenerateDeSerialization()
MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig,
Weaver.voidType);
serialize.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkReaderType)));
serialize.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkReaderType)));
serialize.Parameters.Add(new ParameterDefinition("initialState", ParameterAttributes.None, Weaver.boolType));
ILProcessor serWorker = serialize.Body.GetILProcessor();
MethodReference baseDeserialize = Resolvers.ResolveMethodInParents(m_td.BaseType, Weaver.scriptDef, "OnDeserialize");
MethodReference baseDeserialize = Resolvers.ResolveMethodInParents(m_td.BaseType, Weaver.CurrentAssembly, "OnDeserialize");
if (baseDeserialize != null)
{
serWorker.Append(serWorker.Create(OpCodes.Ldarg_0)); // base
@ -595,7 +587,7 @@ void GenerateDeSerialization()
dirtyBit += 1;
}
if (Weaver.generateLogErrors)
if (Weaver.GenerateLogErrors)
{
serWorker.Append(serWorker.Create(OpCodes.Ldstr, "Injected Deserialize " + m_td.Name));
serWorker.Append(serWorker.Create(OpCodes.Call, Weaver.logErrorReference));
@ -635,8 +627,7 @@ public static bool ProcessNetworkReaderParameters(TypeDefinition td, MethodDefin
}
else
{
Log.Error("ProcessNetworkReaderParameters for " + td.Name + ":" + md.Name + " type " + arg.ParameterType + " not supported");
Weaver.fail = true;
Weaver.Error("ProcessNetworkReaderParameters for " + td.Name + ":" + md.Name + " type " + arg.ParameterType + " not supported");
return false;
}
}
@ -646,27 +637,24 @@ public static bool ProcessNetworkReaderParameters(TypeDefinition td, MethodDefin
public static void AddInvokeParameters(ICollection<ParameterDefinition> collection)
{
collection.Add(new ParameterDefinition("obj", ParameterAttributes.None, Weaver.NetworkBehaviourType2));
collection.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkReaderType)));
collection.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkReaderType)));
}
public static bool ProcessMethodsValidateFunction(TypeDefinition td, MethodReference md, string actionType)
{
if (md.ReturnType.FullName == Weaver.IEnumeratorType.FullName)
{
Log.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot be a coroutine");
Weaver.fail = true;
Weaver.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot be a coroutine");
return false;
}
if (md.ReturnType.FullName != Weaver.voidType.FullName)
{
Log.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] must have a void return type.");
Weaver.fail = true;
Weaver.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] must have a void return type.");
return false;
}
if (md.HasGenericParameters)
{
Log.Error(actionType + " [" + td.FullName + ":" + md.Name + "] cannot have generic parameters");
Weaver.fail = true;
Weaver.Error(actionType + " [" + td.FullName + ":" + md.Name + "] cannot have generic parameters");
return false;
}
return true;
@ -679,46 +667,40 @@ public static bool ProcessMethodsValidateParameters(TypeDefinition td, MethodRef
var p = md.Parameters[i];
if (p.IsOut)
{
Log.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot have out parameters");
Weaver.fail = true;
Weaver.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot have out parameters");
return false;
}
if (p.IsOptional)
{
Log.Error(actionType + "function [" + td.FullName + ":" + md.Name + "] cannot have optional parameters");
Weaver.fail = true;
Weaver.Error(actionType + "function [" + td.FullName + ":" + md.Name + "] cannot have optional parameters");
return false;
}
if (p.ParameterType.Resolve().IsAbstract)
{
Log.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot have abstract parameters");
Weaver.fail = true;
Weaver.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot have abstract parameters");
return false;
}
if (p.ParameterType.IsByReference)
{
Log.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot have ref parameters");
Weaver.fail = true;
Weaver.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] cannot have ref parameters");
return false;
}
// TargetRPC is an exception to this rule and can have a NetworkConnection as first parameter
if (p.ParameterType.FullName == Weaver.NetworkConnectionType.FullName &&
!(ca.AttributeType.FullName == Weaver.TargetRpcType.FullName && i == 0))
{
Log.Error(actionType + " [" + td.FullName + ":" + md.Name + "] cannot use a NetworkConnection as a parameter. To access a player object's connection on the server use connectionToClient");
Log.Error("Name: " + ca.AttributeType.FullName + " parameter: " + md.Parameters[0].ParameterType.FullName);
Weaver.fail = true;
Weaver.Error(actionType + " [" + td.FullName + ":" + md.Name + "] cannot use a NetworkConnection as a parameter. To access a player object's connection on the server use connectionToClient");
Weaver.Error("Name: " + ca.AttributeType.FullName + " parameter: " + md.Parameters[0].ParameterType.FullName);
return false;
}
if (p.ParameterType.Resolve().IsDerivedFrom(Weaver.ComponentType))
{
if (p.ParameterType.FullName != Weaver.NetworkIdentityType.FullName)
{
Log.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] parameter [" + p.Name +
Weaver.Error(actionType + " function [" + td.FullName + ":" + md.Name + "] parameter [" + p.Name +
"] is of the type [" +
p.ParameterType.Name +
"] which is a Component. You cannot pass a Component to a remote call. Try passing data from within the component.");
Weaver.fail = true;
return false;
}
}
@ -743,8 +725,7 @@ void ProcessMethods()
if (names.Contains(md.Name))
{
Log.Error("Duplicate Command name [" + m_td.FullName + ":" + md.Name + "]");
Weaver.fail = true;
Weaver.Error("Duplicate Command name [" + m_td.FullName + ":" + md.Name + "]");
return;
}
names.Add(md.Name);
@ -760,7 +741,7 @@ void ProcessMethods()
if (cmdCallFunc != null)
{
m_CmdCallFuncs.Add(cmdCallFunc);
Weaver.lists.replaceMethods[md.FullName] = cmdCallFunc;
Weaver.WeaveLists.replaceMethods[md.FullName] = cmdCallFunc;
}
break;
}
@ -772,8 +753,7 @@ void ProcessMethods()
if (names.Contains(md.Name))
{
Log.Error("Duplicate Target Rpc name [" + m_td.FullName + ":" + md.Name + "]");
Weaver.fail = true;
Weaver.Error("Duplicate Target Rpc name [" + m_td.FullName + ":" + md.Name + "]");
return;
}
names.Add(md.Name);
@ -789,7 +769,7 @@ void ProcessMethods()
if (rpcCallFunc != null)
{
m_TargetRpcCallFuncs.Add(rpcCallFunc);
Weaver.lists.replaceMethods[md.FullName] = rpcCallFunc;
Weaver.WeaveLists.replaceMethods[md.FullName] = rpcCallFunc;
}
break;
}
@ -801,8 +781,7 @@ void ProcessMethods()
if (names.Contains(md.Name))
{
Log.Error("Duplicate ClientRpc name [" + m_td.FullName + ":" + md.Name + "]");
Weaver.fail = true;
Weaver.Error("Duplicate ClientRpc name [" + m_td.FullName + ":" + md.Name + "]");
return;
}
names.Add(md.Name);
@ -818,7 +797,7 @@ void ProcessMethods()
if (rpcCallFunc != null)
{
m_RpcCallFuncs.Add(rpcCallFunc);
Weaver.lists.replaceMethods[md.FullName] = rpcCallFunc;
Weaver.WeaveLists.replaceMethods[md.FullName] = rpcCallFunc;
}
break;
}

View File

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

View File

@ -38,14 +38,10 @@ public static MethodDefinition ProcessRpcInvoke(TypeDefinition td, MethodDefinit
/* generates code like:
public void CallRpcTest (int param)
{
if (!NetworkServer.get_active ()) {
Debug.LogError ((object)"RPC Function RpcTest called on client.");
} else {
NetworkWriter writer = new NetworkWriter ();
writer.WritePackedUInt32((uint)param);
base.SendRPCInternal(typeof(class),"RpcTest", writer, 0);
}
}
*/
public static MethodDefinition ProcessRpcCall(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
{
@ -64,8 +60,6 @@ public static MethodDefinition ProcessRpcCall(TypeDefinition td, MethodDefinitio
NetworkBehaviourProcessor.WriteSetupLocals(rpcWorker);
NetworkBehaviourProcessor.WriteServerActiveCheck(rpcWorker, md.Name, label, "RPC Function");
NetworkBehaviourProcessor.WriteCreateWriter(rpcWorker);
// write all the arguments that the user passed to the Rpc call
@ -97,15 +91,13 @@ public static bool ProcessMethodsValidateRpc(TypeDefinition td, MethodDefinition
{
if (md.Name.Length > 2 && md.Name.Substring(0, 3) != "Rpc")
{
Log.Error("Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Rpc' prefix");
Weaver.fail = true;
Weaver.Error("Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Rpc' prefix");
return false;
}
if (md.IsStatic)
{
Log.Error("ClientRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method");
Weaver.fail = true;
Weaver.Error("ClientRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method");
return false;
}

View File

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

View File

@ -21,8 +21,7 @@ public static MethodDefinition ProcessEventInvoke(TypeDefinition td, EventDefini
}
if (eventField == null)
{
Weaver.DLog(td, "ERROR: no event field?!");
Weaver.fail = true;
Weaver.Error("[" + td.Name + "] ERROR: no event field?!");
return null;
}
@ -51,7 +50,7 @@ public static MethodDefinition ProcessEventInvoke(TypeDefinition td, EventDefini
cmdWorker.Append(cmdWorker.Create(OpCodes.Ldfld, eventField));
// read the event arguments
MethodReference invoke = Resolvers.ResolveMethod(eventField.FieldType, Weaver.scriptDef, "Invoke");
MethodReference invoke = Resolvers.ResolveMethod(eventField.FieldType, Weaver.CurrentAssembly, "Invoke");
if (!NetworkBehaviourProcessor.ProcessNetworkReaderParameters(td, invoke.Resolve(), cmdWorker, false))
return null;
@ -66,7 +65,7 @@ public static MethodDefinition ProcessEventInvoke(TypeDefinition td, EventDefini
public static MethodDefinition ProcessEventCall(TypeDefinition td, EventDefinition ed, CustomAttribute ca)
{
MethodReference invoke = Resolvers.ResolveMethod(ed.EventType, Weaver.scriptDef, "Invoke");
MethodReference invoke = Resolvers.ResolveMethod(ed.EventType, Weaver.CurrentAssembly, "Invoke");
MethodDefinition evt = new MethodDefinition("Call" + ed.Name, MethodAttributes.Public |
MethodAttributes.HideBySig,
Weaver.voidType);
@ -114,15 +113,13 @@ public static void ProcessEvents(TypeDefinition td, List<EventDefinition> events
{
if (ed.Name.Length > 4 && ed.Name.Substring(0, 5) != "Event")
{
Log.Error("Event [" + td.FullName + ":" + ed.FullName + "] doesnt have 'Event' prefix");
Weaver.fail = true;
Weaver.Error("Event [" + td.FullName + ":" + ed.FullName + "] doesnt have 'Event' prefix");
return;
}
if (ed.EventType.Resolve().HasGenericParameters)
{
Log.Error("Event [" + td.FullName + ":" + ed.FullName + "] cannot have generic parameters");
Weaver.fail = true;
Weaver.Error("Event [" + td.FullName + ":" + ed.FullName + "] cannot have generic parameters");
return;
}
@ -141,7 +138,7 @@ public static void ProcessEvents(TypeDefinition td, List<EventDefinition> events
MethodDefinition eventCallFunc = ProcessEventCall(td, ed, ca);
td.Methods.Add(eventCallFunc);
Weaver.lists.replaceEvents[ed.Name] = eventCallFunc; // original weaver compares .Name, not EventDefinition.
Weaver.WeaveLists.replaceEvents[ed.Name] = eventCallFunc; // original weaver compares .Name, not EventDefinition.
Weaver.DLog(td, " Event: " + ed.Name);
break;

View File

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

View File

@ -6,7 +6,7 @@
namespace Mirror.Weaver
{
public static class SyncListProcessor
public static class SyncListInitializer
{
// generates 'syncListInt = new SyncListInt()' if user didn't do that yet
public static void GenerateSyncListInstanceInitializer(ILProcessor ctorWorker, FieldDefinition fd)
@ -31,12 +31,11 @@ public static void GenerateSyncListInstanceInitializer(ILProcessor ctorWorker, F
MethodReference listCtor;
try
{
listCtor = Weaver.scriptDef.MainModule.ImportReference(fd.FieldType.Resolve().Methods.First<MethodDefinition>(x => x.Name == ".ctor" && !x.HasParameters));
listCtor = Weaver.CurrentAssembly.MainModule.ImportReference(fd.FieldType.Resolve().Methods.First<MethodDefinition>(x => x.Name == ".ctor" && !x.HasParameters));
}
catch (Exception)
{
Weaver.fail = true;
Log.Error("Missing parameter-less constructor for:" + fd.FieldType.Name);
Weaver.Error("Missing parameter-less constructor for:" + fd.FieldType.Name);
return;
}

View File

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

View File

@ -12,17 +12,16 @@ public static void Process(TypeDefinition td)
GenericInstanceType gt = (GenericInstanceType)td.BaseType;
if (gt.GenericArguments.Count == 0)
{
Weaver.fail = true;
Log.Error("SyncListStructProcessor no generic args");
Weaver.Error("SyncListStructProcessor no generic args");
return;
}
TypeReference itemType = Weaver.scriptDef.MainModule.ImportReference(gt.GenericArguments[0]);
TypeReference itemType = Weaver.CurrentAssembly.MainModule.ImportReference(gt.GenericArguments[0]);
Weaver.DLog(td, "SyncListStructProcessor Start item:" + itemType.FullName);
Weaver.ResetRecursionCount();
MethodReference writeItemFunc = GenerateSerialization(td, itemType);
if (Weaver.fail)
if (Weaver.WeavingFailed)
{
return;
}
@ -51,14 +50,13 @@ static MethodReference GenerateSerialization(TypeDefinition td, TypeReference it
MethodAttributes.HideBySig,
Weaver.voidType);
serializeFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkWriterType)));
serializeFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkWriterType)));
serializeFunc.Parameters.Add(new ParameterDefinition("item", ParameterAttributes.None, itemType));
ILProcessor serWorker = serializeFunc.Body.GetILProcessor();
if (itemType.IsGenericInstance)
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + Helpers.PrettyPrintType(itemType) + " failed. Struct passed into SyncListStruct<T> can't have generic parameters");
Weaver.Error("GenerateSerialization for " + Helpers.PrettyPrintType(itemType) + " failed. Struct passed into SyncListStruct<T> can't have generic parameters");
return null;
}
@ -67,20 +65,18 @@ static MethodReference GenerateSerialization(TypeDefinition td, TypeReference it
if (field.IsStatic || field.IsPrivate || field.IsSpecialName)
continue;
FieldReference importedField = Weaver.scriptDef.MainModule.ImportReference(field);
FieldReference importedField = Weaver.CurrentAssembly.MainModule.ImportReference(field);
TypeDefinition ft = importedField.FieldType.Resolve();
if (ft.HasGenericParameters)
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " [" + ft + "/" + ft.FullName + "]. [SyncListStruct] member cannot have generic parameters.");
Weaver.Error("GenerateSerialization for " + td.Name + " [" + ft + "/" + ft.FullName + "]. [SyncListStruct] member cannot have generic parameters.");
return null;
}
if (ft.IsInterface)
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " [" + ft + "/" + ft.FullName + "]. [SyncListStruct] member cannot be an interface.");
Weaver.Error("GenerateSerialization for " + td.Name + " [" + ft + "/" + ft.FullName + "]. [SyncListStruct] member cannot be an interface.");
return null;
}
@ -94,8 +90,7 @@ static MethodReference GenerateSerialization(TypeDefinition td, TypeReference it
}
else
{
Weaver.fail = true;
Log.Error("GenerateSerialization for " + td.Name + " unknown type [" + ft + "/" + ft.FullName + "]. [SyncListStruct] member variables must be basic types.");
Weaver.Error("GenerateSerialization for " + td.Name + " unknown type [" + ft + "/" + ft.FullName + "]. [SyncListStruct] member variables must be basic types.");
return null;
}
}
@ -120,7 +115,7 @@ static MethodReference GenerateDeserialization(TypeDefinition td, TypeReference
MethodAttributes.HideBySig,
itemType);
serializeFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.scriptDef.MainModule.ImportReference(Weaver.NetworkReaderType)));
serializeFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, Weaver.CurrentAssembly.MainModule.ImportReference(Weaver.NetworkReaderType)));
ILProcessor serWorker = serializeFunc.Body.GetILProcessor();
@ -136,7 +131,7 @@ static MethodReference GenerateDeserialization(TypeDefinition td, TypeReference
if (field.IsStatic || field.IsPrivate || field.IsSpecialName)
continue;
FieldReference importedField = Weaver.scriptDef.MainModule.ImportReference(field);
FieldReference importedField = Weaver.CurrentAssembly.MainModule.ImportReference(field);
TypeDefinition ft = importedField.FieldType.Resolve();
MethodReference readerFunc = Weaver.GetReadFunc(field.FieldType);
@ -149,8 +144,7 @@ static MethodReference GenerateDeserialization(TypeDefinition td, TypeReference
}
else
{
Weaver.fail = true;
Log.Error("GenerateDeserialization for " + td.Name + " unknown type [" + ft + "]. [SyncListStruct] member variables must be basic types.");
Weaver.Error("GenerateDeserialization for " + td.Name + " unknown type [" + ft + "]. [SyncListStruct] member variables must be basic types.");
return null;
}
}

View File

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

View File

@ -5,7 +5,7 @@
namespace Mirror.Weaver
{
public static class SyncObjectProcessor
public static class SyncObjectInitializer
{
public static bool ImplementsSyncObject(TypeReference typeRef)
{

View File

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

View File

@ -31,20 +31,17 @@ public static bool CheckForHookFunction(TypeDefinition td, FieldDefinition syncV
{
if (m.Parameters[0].ParameterType != syncVar.FieldType)
{
Log.Error("SyncVar Hook function " + hookFunctionName + " has wrong type signature for " + td.Name);
Weaver.fail = true;
Weaver.Error("SyncVar Hook function " + hookFunctionName + " has wrong type signature for " + td.Name);
return false;
}
foundMethod = m;
return true;
}
Log.Error("SyncVar Hook function " + hookFunctionName + " must have one argument " + td.Name);
Weaver.fail = true;
Weaver.Error("SyncVar Hook function " + hookFunctionName + " must have one argument " + td.Name);
return false;
}
}
Log.Error("SyncVar Hook function " + hookFunctionName + " not found for " + td.Name);
Weaver.fail = true;
Weaver.Error("SyncVar Hook function " + hookFunctionName + " not found for " + td.Name);
return false;
}
}
@ -222,7 +219,7 @@ public static void ProcessSyncVar(TypeDefinition td, FieldDefinition fd, Diction
td.Methods.Add(get);
td.Methods.Add(set);
td.Properties.Add(propertyDefinition);
Weaver.lists.replacementSetterProperties[fd] = set;
Weaver.WeaveLists.replacementSetterProperties[fd] = set;
// replace getter field if GameObject/NetworkIdentity so it uses
// netId instead
@ -231,7 +228,7 @@ public static void ProcessSyncVar(TypeDefinition td, FieldDefinition fd, Diction
if (fd.FieldType.FullName == Weaver.gameObjectType.FullName ||
fd.FieldType.FullName == Weaver.NetworkIdentityType.FullName)
{
Weaver.lists.replacementGetterProperties[fd] = get;
Weaver.WeaveLists.replacementGetterProperties[fd] = get;
}
}
@ -256,61 +253,54 @@ public static void ProcessSyncVars(TypeDefinition td, List<FieldDefinition> sync
if (resolvedField.IsDerivedFrom(Weaver.NetworkBehaviourType))
{
Log.Error("SyncVar [" + fd.FullName + "] cannot be derived from NetworkBehaviour.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] cannot be derived from NetworkBehaviour.");
return;
}
if (resolvedField.IsDerivedFrom(Weaver.ScriptableObjectType))
{
Log.Error("SyncVar [" + fd.FullName + "] cannot be derived from ScriptableObject.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] cannot be derived from ScriptableObject.");
return;
}
if ((fd.Attributes & FieldAttributes.Static) != 0)
{
Log.Error("SyncVar [" + fd.FullName + "] cannot be static.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] cannot be static.");
return;
}
if (resolvedField.HasGenericParameters)
{
Log.Error("SyncVar [" + fd.FullName + "] cannot have generic parameters.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] cannot have generic parameters.");
return;
}
if (resolvedField.IsInterface)
{
Log.Error("SyncVar [" + fd.FullName + "] cannot be an interface.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] cannot be an interface.");
return;
}
var fieldModuleName = resolvedField.Module.Name;
if (fieldModuleName != Weaver.scriptDef.MainModule.Name &&
fieldModuleName != Weaver.m_UnityAssemblyDefinition.MainModule.Name &&
fieldModuleName != Weaver.m_UNetAssemblyDefinition.MainModule.Name &&
fieldModuleName != Weaver.corLib.Name &&
if (fieldModuleName != Weaver.CurrentAssembly.MainModule.Name &&
fieldModuleName != Weaver.UnityAssembly.MainModule.Name &&
fieldModuleName != Weaver.NetAssembly.MainModule.Name &&
fieldModuleName != Weaver.CorLibModule.Name &&
fieldModuleName != "System.Runtime.dll" && // this is only for Metro, built-in types are not in corlib on metro
fieldModuleName != "netstandard.dll" // handle built-in types when weaving new C#7 compiler assemblies
)
{
Log.Error("SyncVar [" + fd.FullName + "] from " + resolvedField.Module.ToString() + " cannot be a different module.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] from " + resolvedField.Module.ToString() + " cannot be a different module.");
return;
}
if (fd.FieldType.IsArray)
{
Log.Error("SyncVar [" + fd.FullName + "] cannot be an array. Use a SyncList instead.");
Weaver.fail = true;
Weaver.Error("SyncVar [" + fd.FullName + "] cannot be an array. Use a SyncList instead.");
return;
}
if (SyncObjectProcessor.ImplementsSyncObject(fd.FieldType))
if (SyncObjectInitializer.ImplementsSyncObject(fd.FieldType))
{
Log.Warning(string.Format("Script class [{0}] has [SyncVar] attribute on SyncList field {1}, SyncLists should not be marked with SyncVar.", td.FullName, fd.Name));
break;
@ -324,8 +314,7 @@ public static void ProcessSyncVars(TypeDefinition td, List<FieldDefinition> sync
if (dirtyBitCounter == k_SyncVarLimit)
{
Log.Error("Script class [" + td.FullName + "] has too many SyncVars (" + k_SyncVarLimit + "). (This could include base classes)");
Weaver.fail = true;
Weaver.Error("Script class [" + td.FullName + "] has too many SyncVars (" + k_SyncVarLimit + "). (This could include base classes)");
return;
}
break;
@ -334,8 +323,7 @@ public static void ProcessSyncVars(TypeDefinition td, List<FieldDefinition> sync
if (fd.FieldType.FullName.Contains("Mirror.SyncListStruct"))
{
Log.Error("SyncListStruct member variable [" + fd.FullName + "] must use a dervied class, like \"class MySyncList : SyncListStruct<MyStruct> {}\".");
Weaver.fail = true;
Weaver.Error("SyncListStruct member variable [" + fd.FullName + "] must use a dervied class, like \"class MySyncList : SyncListStruct<MyStruct> {}\".");
return;
}
@ -343,8 +331,7 @@ public static void ProcessSyncVars(TypeDefinition td, List<FieldDefinition> sync
{
if (fd.IsStatic)
{
Log.Error("SyncList [" + td.FullName + ":" + fd.FullName + "] cannot be a static");
Weaver.fail = true;
Weaver.Error("SyncList [" + td.FullName + ":" + fd.FullName + "] cannot be a static");
return;
}

View File

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

View File

@ -8,6 +8,13 @@ public static class TargetRpcProcessor
{
const string k_TargetRpcPrefix = "InvokeTargetRpc";
// helper functions to check if the method has a NetworkConnection parameter
public static bool HasNetworkConnectionParameter(MethodDefinition md)
{
return md.Parameters.Count > 0 &&
md.Parameters[0].ParameterType.FullName == Weaver.NetworkConnectionType.FullName;
}
public static MethodDefinition ProcessTargetRpcInvoke(TypeDefinition td, MethodDefinition md)
{
MethodDefinition rpc = new MethodDefinition(RpcProcessor.k_RpcPrefix + md.Name, MethodAttributes.Family |
@ -24,10 +31,16 @@ public static MethodDefinition ProcessTargetRpcInvoke(TypeDefinition td, MethodD
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldarg_0));
rpcWorker.Append(rpcWorker.Create(OpCodes.Castclass, td));
// NetworkConnection parameter is optional
bool hasNetworkConnection = HasNetworkConnectionParameter(md);
if (hasNetworkConnection)
{
//ClientScene.readyconnection
rpcWorker.Append(rpcWorker.Create(OpCodes.Call, Weaver.ReadyConnectionReference));
}
if (!NetworkBehaviourProcessor.ProcessNetworkReaderParameters(td, md, rpcWorker, true))
// process reader parameters and skip first one if first one is NetworkConnection
if (!NetworkBehaviourProcessor.ProcessNetworkReaderParameters(td, md, rpcWorker, hasNetworkConnection))
return null;
// invoke actual command function
@ -42,15 +55,17 @@ public static MethodDefinition ProcessTargetRpcInvoke(TypeDefinition td, MethodD
/* generates code like:
public void CallTargetTest (NetworkConnection conn, int param)
{
if (!NetworkServer.get_active ()) {
Debug.LogError((object)"TargetRPC Function TargetTest called on client.");
} else if (((?)conn) is ULocalConnectionToServer) {
Debug.LogError((object)"TargetRPC Function TargetTest called on connection to server");
} else {
NetworkWriter writer = new NetworkWriter ();
writer.WritePackedUInt32 ((uint)param);
base.SendTargetRPCInternal (conn, typeof(class), "TargetTest", val);
}
or if optional:
public void CallTargetTest (int param)
{
NetworkWriter writer = new NetworkWriter ();
writer.WritePackedUInt32 ((uint)param);
base.SendTargetRPCInternal (null, typeof(class), "TargetTest", val);
}
*/
public static MethodDefinition ProcessTargetRpcCall(TypeDefinition td, MethodDefinition md, CustomAttribute ca)
@ -59,35 +74,24 @@ public static MethodDefinition ProcessTargetRpcCall(TypeDefinition td, MethodDef
MethodAttributes.HideBySig,
Weaver.voidType);
// add paramters
// add parameters
foreach (ParameterDefinition pd in md.Parameters)
{
rpc.Parameters.Add(new ParameterDefinition(pd.Name, ParameterAttributes.None, pd.ParameterType));
}
ILProcessor rpcWorker = rpc.Body.GetILProcessor();
Instruction label = rpcWorker.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteSetupLocals(rpcWorker);
NetworkBehaviourProcessor.WriteServerActiveCheck(rpcWorker, md.Name, label, "TargetRPC Function");
Instruction labelConnectionCheck = rpcWorker.Create(OpCodes.Nop);
// check specifically for ULocalConnectionToServer so a host is not trying to send
// an TargetRPC to the "server" from it's local client.
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldarg_1));
rpcWorker.Append(rpcWorker.Create(OpCodes.Isinst, Weaver.ULocalConnectionToServerType));
rpcWorker.Append(rpcWorker.Create(OpCodes.Brfalse, labelConnectionCheck));
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldstr, string.Format("TargetRPC Function {0} called on connection to server", md.Name)));
rpcWorker.Append(rpcWorker.Create(OpCodes.Call, Weaver.logErrorReference));
rpcWorker.Append(rpcWorker.Create(OpCodes.Ret));
rpcWorker.Append(labelConnectionCheck);
NetworkBehaviourProcessor.WriteCreateWriter(rpcWorker);
// NetworkConnection parameter is optional
bool hasNetworkConnection = HasNetworkConnectionParameter(md);
// write all the arguments that the user passed to the TargetRpc call
if (!NetworkBehaviourProcessor.WriteArguments(rpcWorker, md, "TargetRPC", true))
// (skip first one if first one is NetworkConnection)
if (!NetworkBehaviourProcessor.WriteArguments(rpcWorker, md, "TargetRPC", hasNetworkConnection))
return null;
var rpcName = md.Name;
@ -99,7 +103,14 @@ public static MethodDefinition ProcessTargetRpcCall(TypeDefinition td, MethodDef
// invoke SendInternal and return
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldarg_0)); // this
if (HasNetworkConnectionParameter(md))
{
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldarg_1)); // connection
}
else
{
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldnull)); // null
}
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldtoken, td));
rpcWorker.Append(rpcWorker.Create(OpCodes.Call, Weaver.getTypeFromHandleReference)); // invokerClass
rpcWorker.Append(rpcWorker.Create(OpCodes.Ldstr, rpcName));
@ -119,15 +130,13 @@ public static bool ProcessMethodsValidateTargetRpc(TypeDefinition td, MethodDefi
if (md.Name.Length > prefixLen && md.Name.Substring(0, prefixLen) != targetPrefix)
{
Log.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Target' prefix");
Weaver.fail = true;
Weaver.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] doesnt have 'Target' prefix");
return false;
}
if (md.IsStatic)
{
Log.Error("TargetRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method");
Weaver.fail = true;
Weaver.Error("TargetRpc function [" + td.FullName + ":" + md.Name + "] cant be a static method");
return false;
}
@ -136,20 +145,6 @@ public static bool ProcessMethodsValidateTargetRpc(TypeDefinition td, MethodDefi
return false;
}
if (md.Parameters.Count < 1)
{
Log.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] must have a NetworkConnection as the first parameter");
Weaver.fail = true;
return false;
}
if (md.Parameters[0].ParameterType.FullName != Weaver.NetworkConnectionType.FullName)
{
Log.Error("Target Rpc function [" + td.FullName + ":" + md.Name + "] first parameter must be a NetworkConnection");
Weaver.fail = true;
return false;
}
// validate
return NetworkBehaviourProcessor.ProcessMethodsValidateParameters(td, md, ca, "Target Rpc");
}

View File

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

View File

@ -23,15 +23,15 @@ public static void Error(string msg)
public class Program
{
public static bool Process(string unityEngine, string unetDLL, string outputDirectory, string[] assemblies, string[] extraAssemblyPaths, IAssemblyResolver assemblyResolver, Action<string> printWarning, Action<string> printError)
public static bool Process(string unityEngine, string netDLL, string outputDirectory, string[] assemblies, string[] extraAssemblyPaths, Action<string> printWarning, Action<string> printError)
{
CheckDLLPath(unityEngine);
CheckDLLPath(unetDLL);
CheckDLLPath(netDLL);
CheckOutputDirectory(outputDirectory);
CheckAssemblies(assemblies);
Log.WarningMethod = printWarning;
Log.ErrorMethod = printError;
return Weaver.WeaveAssemblies(assemblies, extraAssemblyPaths, assemblyResolver, outputDirectory, unityEngine, unetDLL);
return Weaver.WeaveAssemblies(assemblies, extraAssemblyPaths, null, outputDirectory, unityEngine, netDLL);
}
private static void CheckDLLPath(string path)

View File

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

View File

@ -15,8 +15,7 @@ public static MethodReference ResolveMethod(TypeReference tr, AssemblyDefinition
//Console.WriteLine("ResolveMethod " + t.ToString () + " " + name);
if (tr == null)
{
Log.Error("Type missing for " + name);
Weaver.fail = true;
Weaver.Error("Type missing for " + name);
return null;
}
foreach (MethodDefinition methodRef in tr.Resolve().Methods)
@ -26,15 +25,14 @@ public static MethodReference ResolveMethod(TypeReference tr, AssemblyDefinition
return scriptDef.MainModule.ImportReference(methodRef);
}
}
Log.Error("ResolveMethod failed " + tr.Name + "::" + name + " " + tr.Resolve());
Weaver.Error("ResolveMethod failed " + tr.Name + "::" + name + " " + tr.Resolve());
// why did it fail!?
foreach (MethodDefinition methodRef in tr.Resolve().Methods)
{
Log.Error("Method " + methodRef.Name);
Weaver.Error("Method " + methodRef.Name);
}
Weaver.fail = true;
return null;
}
@ -43,8 +41,7 @@ public static MethodReference ResolveMethodInParents(TypeReference tr, AssemblyD
{
if (tr == null)
{
Log.Error("Type missing for " + name);
Weaver.fail = true;
Weaver.Error("Type missing for " + name);
return null;
}
foreach (MethodDefinition methodRef in tr.Resolve().Methods)
@ -74,8 +71,7 @@ public static MethodReference ResolveMethodWithArg(TypeReference tr, AssemblyDef
}
}
}
Log.Error("ResolveMethodWithArg failed " + tr.Name + "::" + name + " " + argTypeFullName);
Weaver.fail = true;
Weaver.Error("ResolveMethodWithArg failed " + tr.Name + "::" + name + " " + argTypeFullName);
return null;
}
@ -121,8 +117,7 @@ public static GenericInstanceMethod ResolveMethodGeneric(TypeReference t, Assemb
}
}
Log.Error("ResolveMethodGeneric failed " + t.Name + "::" + name + " " + genericType);
Weaver.fail = true;
Weaver.Error("ResolveMethodGeneric failed " + t.Name + "::" + name + " " + genericType);
return null;
}

View File

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

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@ -38,14 +38,29 @@ class WeaverLists
class Weaver
{
// UNetwork types
public static WeaverLists WeaveLists { get; private set; }
public static AssemblyDefinition CurrentAssembly { get; private set; }
public static ModuleDefinition CorLibModule { get; private set; }
public static AssemblyDefinition UnityAssembly { get; private set; }
public static AssemblyDefinition NetAssembly { get; private set; }
public static bool WeavingFailed { get; private set; }
public static bool GenerateLogErrors { get; set; }
// private properties
static bool DebugLogEnabled = true;
// this is used to prevent stack overflows when generating serialization code when there are self-referencing types.
// All the utility classes use GetWriteFunc() to generate serialization code, so the recursion check is implemented there instead of in each utility class.
// A NetworkBehaviour with the max SyncVars (64) can legitimately increment this value to 65 - so max must be higher than that
const int MaxRecursionCount = 128;
static int RecursionCount;
// Network types
public static TypeReference NetworkBehaviourType;
public static TypeReference NetworkBehaviourType2;
public static TypeReference MonoBehaviourType;
public static TypeReference ScriptableObjectType;
public static TypeReference NetworkConnectionType;
public static TypeReference ULocalConnectionToServerType;
public static TypeReference ULocalConnectionToClientType;
public static TypeReference MessageBaseType;
public static TypeReference SyncListStructType;
@ -63,7 +78,7 @@ class Weaver
public static MethodReference NetworkWriterCtor;
public static MethodReference NetworkReaderCtor;
public static MethodReference getComponentReference;
public static MethodReference getUNetIdReference;
public static MethodReference getNetIdReference;
public static TypeReference NetworkIdentityType;
public static TypeReference IEnumeratorType;
@ -156,60 +171,50 @@ class Weaver
public static MethodReference sendTargetRpcInternal;
public static MethodReference sendEventInternal;
public static WeaverLists lists;
public static AssemblyDefinition scriptDef;
public static ModuleDefinition corLib;
public static AssemblyDefinition m_UnityAssemblyDefinition;
public static AssemblyDefinition m_UNetAssemblyDefinition;
static bool m_DebugFlag = true;
public static bool fail;
public static bool generateLogErrors = false;
// this is used to prevent stack overflows when generating serialization code when there are self-referencing types.
// All the utility classes use GetWriteFunc() to generate serialization code, so the recursion check is implemented there instead of in each utility class.
// A NetworkBehaviour with the max SyncVars (32) can legitimately increment this value to 65 - so max must be higher than that
const int MaxRecursionCount = 128;
static int s_RecursionCount;
public static void ResetRecursionCount()
{
s_RecursionCount = 0;
RecursionCount = 0;
}
public static void DLog(TypeDefinition td, string fmt, params object[] args)
{
if (!m_DebugFlag)
if (!DebugLogEnabled)
return;
Console.WriteLine("[" + td.Name + "] " + String.Format(fmt, args));
}
// display weaver error
// and mark process as failed
public static void Error(string message)
{
Log.Error(message);
WeavingFailed = true;
}
public static int GetSyncVarStart(string className)
{
return lists.numSyncVars.ContainsKey(className)
? lists.numSyncVars[className]
return WeaveLists.numSyncVars.ContainsKey(className)
? WeaveLists.numSyncVars[className]
: 0;
}
public static void SetNumSyncVars(string className, int num)
{
lists.numSyncVars[className] = num;
WeaveLists.numSyncVars[className] = num;
}
public static MethodReference GetWriteFunc(TypeReference variable)
{
if (s_RecursionCount++ > MaxRecursionCount)
if (RecursionCount++ > MaxRecursionCount)
{
Log.Error("GetWriteFunc recursion depth exceeded for " + variable.Name + ". Check for self-referencing member variables.");
fail = true;
Error("GetWriteFunc recursion depth exceeded for " + variable.Name + ". Check for self-referencing member variables.");
return null;
}
if (lists.writeFuncs.ContainsKey(variable.FullName))
if (WeaveLists.writeFuncs.ContainsKey(variable.FullName))
{
MethodReference foundFunc = lists.writeFuncs[variable.FullName];
MethodReference foundFunc = WeaveLists.writeFuncs[variable.FullName];
if (foundFunc.Parameters[0].ParameterType.IsArray == variable.IsArray)
{
return foundFunc;
@ -219,7 +224,7 @@ public static MethodReference GetWriteFunc(TypeReference variable)
if (variable.IsByReference)
{
// error??
Log.Error("GetWriteFunc variable.IsByReference error.");
Error("GetWriteFunc variable.IsByReference error.");
return null;
}
@ -256,18 +261,18 @@ public static MethodReference GetWriteFunc(TypeReference variable)
public static void RegisterWriteFunc(string name, MethodDefinition newWriterFunc)
{
lists.writeFuncs[name] = newWriterFunc;
lists.generatedWriteFunctions.Add(newWriterFunc);
WeaveLists.writeFuncs[name] = newWriterFunc;
WeaveLists.generatedWriteFunctions.Add(newWriterFunc);
ConfirmGeneratedCodeClass(scriptDef.MainModule);
lists.generateContainerClass.Methods.Add(newWriterFunc);
ConfirmGeneratedCodeClass(CurrentAssembly.MainModule);
WeaveLists.generateContainerClass.Methods.Add(newWriterFunc);
}
public static MethodReference GetReadFunc(TypeReference variable)
{
if (lists.readFuncs.ContainsKey(variable.FullName))
if (WeaveLists.readFuncs.ContainsKey(variable.FullName))
{
MethodReference foundFunc = lists.readFuncs[variable.FullName];
MethodReference foundFunc = WeaveLists.readFuncs[variable.FullName];
if (foundFunc.ReturnType.IsArray == variable.IsArray)
{
return foundFunc;
@ -277,14 +282,14 @@ public static MethodReference GetReadFunc(TypeReference variable)
TypeDefinition td = variable.Resolve();
if (td == null)
{
Log.Error("GetReadFunc unsupported type " + variable.FullName);
Error("GetReadFunc unsupported type " + variable.FullName);
return null;
}
if (variable.IsByReference)
{
// error??
Log.Error("GetReadFunc variable.IsByReference error.");
Error("GetReadFunc variable.IsByReference error.");
return null;
}
@ -321,11 +326,11 @@ public static MethodReference GetReadFunc(TypeReference variable)
public static void RegisterReadFunc(string name, MethodDefinition newReaderFunc)
{
lists.readFuncs[name] = newReaderFunc;
lists.generatedReadFunctions.Add(newReaderFunc);
WeaveLists.readFuncs[name] = newReaderFunc;
WeaveLists.generatedReadFunctions.Add(newReaderFunc);
ConfirmGeneratedCodeClass(scriptDef.MainModule);
lists.generateContainerClass.Methods.Add(newReaderFunc);
ConfirmGeneratedCodeClass(CurrentAssembly.MainModule);
WeaveLists.generateContainerClass.Methods.Add(newReaderFunc);
}
static MethodDefinition GenerateArrayReadFunc(TypeReference variable, MethodReference elementReadFunc)
@ -352,7 +357,7 @@ static MethodDefinition GenerateArrayReadFunc(TypeReference variable, MethodRefe
MethodAttributes.HideBySig,
variable);
readerFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, scriptDef.MainModule.ImportReference(NetworkReaderType)));
readerFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, CurrentAssembly.MainModule.ImportReference(NetworkReaderType)));
readerFunc.Body.Variables.Add(new VariableDefinition(int32Type));
readerFunc.Body.Variables.Add(new VariableDefinition(variable));
@ -435,8 +440,8 @@ static MethodDefinition GenerateArrayWriteFunc(TypeReference variable, MethodRef
MethodAttributes.HideBySig,
voidType);
writerFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, scriptDef.MainModule.ImportReference(NetworkWriterType)));
writerFunc.Parameters.Add(new ParameterDefinition("value", ParameterAttributes.None, scriptDef.MainModule.ImportReference(variable)));
writerFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, CurrentAssembly.MainModule.ImportReference(NetworkWriterType)));
writerFunc.Parameters.Add(new ParameterDefinition("value", ParameterAttributes.None, CurrentAssembly.MainModule.ImportReference(variable)));
writerFunc.Body.Variables.Add(new VariableDefinition(uint16Type));
writerFunc.Body.Variables.Add(new VariableDefinition(uint16Type));
@ -523,8 +528,8 @@ static MethodDefinition GenerateWriterFunction(TypeReference variable)
MethodAttributes.HideBySig,
voidType);
writerFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, scriptDef.MainModule.ImportReference(NetworkWriterType)));
writerFunc.Parameters.Add(new ParameterDefinition("value", ParameterAttributes.None, scriptDef.MainModule.ImportReference(variable)));
writerFunc.Parameters.Add(new ParameterDefinition("writer", ParameterAttributes.None, CurrentAssembly.MainModule.ImportReference(NetworkWriterType)));
writerFunc.Parameters.Add(new ParameterDefinition("value", ParameterAttributes.None, CurrentAssembly.MainModule.ImportReference(variable)));
ILProcessor worker = writerFunc.Body.GetILProcessor();
@ -536,15 +541,13 @@ static MethodDefinition GenerateWriterFunction(TypeReference variable)
if (field.FieldType.Resolve().HasGenericParameters)
{
Weaver.fail = true;
Log.Error("WriteReadFunc for " + field.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. Cannot have generic parameters.");
Weaver.Error("WriteReadFunc for " + field.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. Cannot have generic parameters.");
return null;
}
if (field.FieldType.Resolve().IsInterface)
{
Weaver.fail = true;
Log.Error("WriteReadFunc for " + field.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. Cannot be an interface.");
Weaver.Error("WriteReadFunc for " + field.Name + " [" + field.FieldType + "/" + field.FieldType.FullName + "]. Cannot be an interface.");
return null;
}
@ -559,8 +562,7 @@ static MethodDefinition GenerateWriterFunction(TypeReference variable)
}
else
{
Log.Error("WriteReadFunc for " + field.Name + " type " + field.FieldType + " no supported");
fail = true;
Weaver.Error("WriteReadFunc for " + field.Name + " type " + field.FieldType + " no supported");
return null;
}
}
@ -574,10 +576,9 @@ static MethodDefinition GenerateWriterFunction(TypeReference variable)
static MethodDefinition GenerateReadFunction(TypeReference variable)
{
if (s_RecursionCount++ > MaxRecursionCount)
if (RecursionCount++ > MaxRecursionCount)
{
Log.Error("GetReadFunc recursion depth exceeded for " + variable.Name + ". Check for self-referencing member variables.");
fail = true;
Weaver.Error("GetReadFunc recursion depth exceeded for " + variable.Name + ". Check for self-referencing member variables.");
return null;
}
@ -607,7 +608,7 @@ static MethodDefinition GenerateReadFunction(TypeReference variable)
readerFunc.Body.Variables.Add(new VariableDefinition(variable));
readerFunc.Body.InitLocals = true;
readerFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, scriptDef.MainModule.ImportReference(NetworkReaderType)));
readerFunc.Parameters.Add(new ParameterDefinition("reader", ParameterAttributes.None, CurrentAssembly.MainModule.ImportReference(NetworkReaderType)));
ILProcessor worker = readerFunc.Body.GetILProcessor();
@ -650,8 +651,7 @@ static MethodDefinition GenerateReadFunction(TypeReference variable)
}
else
{
Log.Error("GetReadFunc for " + field.Name + " type " + field.FieldType + " no supported");
fail = true;
Weaver.Error("GetReadFunc for " + field.Name + " type " + field.FieldType + " no supported");
return null;
}
@ -693,7 +693,7 @@ static void ProcessInstructionMethod(ModuleDefinition moduleDef, TypeDefinition
// that's why we use dict<string,method>.
// TODO maybe replaceEvents[md] would work too?
MethodDefinition replacement;
if (lists.replaceEvents.TryGetValue(opField.Name, out replacement))
if (WeaveLists.replaceEvents.TryGetValue(opField.Name, out replacement))
{
instr.Operand = replacement;
inst.OpCode = OpCodes.Nop;
@ -709,7 +709,7 @@ static void ProcessInstructionMethod(ModuleDefinition moduleDef, TypeDefinition
// that's why we use dict<string,method>.
// TODO maybe replaceMethods[md] would work too?
MethodDefinition replacement;
if (lists.replaceMethods.TryGetValue(opMethodRef.FullName, out replacement))
if (WeaveLists.replaceMethods.TryGetValue(opMethodRef.FullName, out replacement))
{
//DLog(td, " replacing " + md.Name + ":" + i);
instr.Operand = replacement;
@ -720,19 +720,19 @@ static void ProcessInstructionMethod(ModuleDefinition moduleDef, TypeDefinition
static void ConfirmGeneratedCodeClass(ModuleDefinition moduleDef)
{
if (lists.generateContainerClass == null)
if (WeaveLists.generateContainerClass == null)
{
lists.generateContainerClass = new TypeDefinition("Mirror", "GeneratedNetworkCode",
WeaveLists.generateContainerClass = new TypeDefinition("Mirror", "GeneratedNetworkCode",
TypeAttributes.BeforeFieldInit | TypeAttributes.Class | TypeAttributes.AnsiClass | TypeAttributes.Public | TypeAttributes.AutoClass,
objectType);
const MethodAttributes methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName;
MethodDefinition method = new MethodDefinition(".ctor", methodAttributes, voidType);
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ldarg_0));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Call, Resolvers.ResolveMethod(objectType, scriptDef, ".ctor")));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Call, Resolvers.ResolveMethod(objectType, CurrentAssembly, ".ctor")));
method.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
lists.generateContainerClass.Methods.Add(method);
WeaveLists.generateContainerClass.Methods.Add(method);
}
}
@ -745,7 +745,7 @@ static void ProcessInstructionSetterField(TypeDefinition td, MethodDefinition md
// does it set a field that we replaced?
MethodDefinition replacement;
if (lists.replacementSetterProperties.TryGetValue(opField, out replacement))
if (WeaveLists.replacementSetterProperties.TryGetValue(opField, out replacement))
{
//replace with property
//DLog(td, " replacing " + md.Name + ":" + i);
@ -764,7 +764,7 @@ static void ProcessInstructionGetterField(TypeDefinition td, MethodDefinition md
// does it set a field that we replaced?
MethodDefinition replacement;
if (lists.replacementGetterProperties.TryGetValue(opField, out replacement))
if (WeaveLists.replacementGetterProperties.TryGetValue(opField, out replacement))
{
//replace with property
//DLog(td, " replacing " + md.Name + ":" + i);
@ -972,19 +972,19 @@ static void ProcessSitesModule(ModuleDefinition moduleDef)
ProcessSiteClass(moduleDef, td);
}
}
if (lists.generateContainerClass != null)
if (WeaveLists.generateContainerClass != null)
{
moduleDef.Types.Add(lists.generateContainerClass);
scriptDef.MainModule.ImportReference(lists.generateContainerClass);
moduleDef.Types.Add(WeaveLists.generateContainerClass);
CurrentAssembly.MainModule.ImportReference(WeaveLists.generateContainerClass);
foreach (MethodDefinition f in lists.generatedReadFunctions)
foreach (MethodDefinition f in WeaveLists.generatedReadFunctions)
{
scriptDef.MainModule.ImportReference(f);
CurrentAssembly.MainModule.ImportReference(f);
}
foreach (MethodDefinition f in lists.generatedWriteFunctions)
foreach (MethodDefinition f in WeaveLists.generatedWriteFunctions)
{
scriptDef.MainModule.ImportReference(f);
CurrentAssembly.MainModule.ImportReference(f);
}
}
Console.WriteLine(" ProcessSitesModule " + moduleDef.Name + " elapsed time:" + (DateTime.Now - startTime));
@ -992,7 +992,7 @@ static void ProcessSitesModule(ModuleDefinition moduleDef)
static void ProcessPropertySites()
{
ProcessSitesModule(scriptDef.MainModule);
ProcessSitesModule(CurrentAssembly.MainModule);
}
static bool ProcessNetworkBehaviourType(TypeDefinition td)
@ -1010,29 +1010,29 @@ static bool ProcessNetworkBehaviourType(TypeDefinition td)
static void SetupUnityTypes()
{
vector2Type = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Vector2");
vector3Type = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Vector3");
vector4Type = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Vector4");
colorType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Color");
color32Type = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Color32");
quaternionType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Quaternion");
rectType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Rect");
planeType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Plane");
rayType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Ray");
matrixType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Matrix4x4");
gameObjectType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.GameObject");
transformType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Transform");
unityObjectType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Object");
vector2Type = UnityAssembly.MainModule.GetType("UnityEngine.Vector2");
vector3Type = UnityAssembly.MainModule.GetType("UnityEngine.Vector3");
vector4Type = UnityAssembly.MainModule.GetType("UnityEngine.Vector4");
colorType = UnityAssembly.MainModule.GetType("UnityEngine.Color");
color32Type = UnityAssembly.MainModule.GetType("UnityEngine.Color32");
quaternionType = UnityAssembly.MainModule.GetType("UnityEngine.Quaternion");
rectType = UnityAssembly.MainModule.GetType("UnityEngine.Rect");
planeType = UnityAssembly.MainModule.GetType("UnityEngine.Plane");
rayType = UnityAssembly.MainModule.GetType("UnityEngine.Ray");
matrixType = UnityAssembly.MainModule.GetType("UnityEngine.Matrix4x4");
gameObjectType = UnityAssembly.MainModule.GetType("UnityEngine.GameObject");
transformType = UnityAssembly.MainModule.GetType("UnityEngine.Transform");
unityObjectType = UnityAssembly.MainModule.GetType("UnityEngine.Object");
NetworkClientType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkClient");
NetworkServerType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkServer");
NetworkClientType = NetAssembly.MainModule.GetType("Mirror.NetworkClient");
NetworkServerType = NetAssembly.MainModule.GetType("Mirror.NetworkServer");
SyncVarType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.SyncVarAttribute");
CommandType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.CommandAttribute");
ClientRpcType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.ClientRpcAttribute");
TargetRpcType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.TargetRpcAttribute");
SyncEventType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.SyncEventAttribute");
SyncObjectType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.SyncObject");
SyncVarType = NetAssembly.MainModule.GetType("Mirror.SyncVarAttribute");
CommandType = NetAssembly.MainModule.GetType("Mirror.CommandAttribute");
ClientRpcType = NetAssembly.MainModule.GetType("Mirror.ClientRpcAttribute");
TargetRpcType = NetAssembly.MainModule.GetType("Mirror.TargetRpcAttribute");
SyncEventType = NetAssembly.MainModule.GetType("Mirror.SyncEventAttribute");
SyncObjectType = NetAssembly.MainModule.GetType("Mirror.SyncObject");
}
static void SetupCorLib()
@ -1040,15 +1040,15 @@ static void SetupCorLib()
AssemblyNameReference name = AssemblyNameReference.Parse("mscorlib");
ReaderParameters parameters = new ReaderParameters
{
AssemblyResolver = scriptDef.MainModule.AssemblyResolver,
AssemblyResolver = CurrentAssembly.MainModule.AssemblyResolver,
};
corLib = scriptDef.MainModule.AssemblyResolver.Resolve(name, parameters).MainModule;
CorLibModule = CurrentAssembly.MainModule.AssemblyResolver.Resolve(name, parameters).MainModule;
}
static TypeReference ImportCorLibType(string fullName)
{
TypeDefinition type = corLib.GetType(fullName) ?? corLib.ExportedTypes.First(t => t.FullName == fullName).Resolve();
return scriptDef.MainModule.ImportReference(type);
TypeDefinition type = CorLibModule.GetType(fullName) ?? CorLibModule.ExportedTypes.First(t => t.FullName == fullName).Resolve();
return CurrentAssembly.MainModule.ImportReference(type);
}
static void SetupTargetTypes()
@ -1076,108 +1076,102 @@ static void SetupTargetTypes()
IEnumeratorType = ImportCorLibType("System.Collections.IEnumerator");
guidType = ImportCorLibType("System.Guid");
NetworkReaderType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkReader");
NetworkReaderType = NetAssembly.MainModule.GetType("Mirror.NetworkReader");
NetworkReaderDef = NetworkReaderType.Resolve();
NetworkReaderCtor = Resolvers.ResolveMethod(NetworkReaderDef, scriptDef, ".ctor");
NetworkReaderCtor = Resolvers.ResolveMethod(NetworkReaderDef, CurrentAssembly, ".ctor");
NetworkWriterType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkWriter");
NetworkWriterType = NetAssembly.MainModule.GetType("Mirror.NetworkWriter");
NetworkWriterDef = NetworkWriterType.Resolve();
NetworkWriterCtor = Resolvers.ResolveMethod(NetworkWriterDef, scriptDef, ".ctor");
NetworkWriterCtor = Resolvers.ResolveMethod(NetworkWriterDef, CurrentAssembly, ".ctor");
NetworkServerGetActive = Resolvers.ResolveMethod(NetworkServerType, scriptDef, "get_active");
NetworkServerGetLocalClientActive = Resolvers.ResolveMethod(NetworkServerType, scriptDef, "get_localClientActive");
NetworkClientGetActive = Resolvers.ResolveMethod(NetworkClientType, scriptDef, "get_active");
NetworkServerGetActive = Resolvers.ResolveMethod(NetworkServerType, CurrentAssembly, "get_active");
NetworkServerGetLocalClientActive = Resolvers.ResolveMethod(NetworkServerType, CurrentAssembly, "get_localClientActive");
NetworkClientGetActive = Resolvers.ResolveMethod(NetworkClientType, CurrentAssembly, "get_active");
NetworkReaderReadInt32 = Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadInt32");
NetworkReaderReadInt32 = Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadInt32");
NetworkWriterWriteInt32 = Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", int32Type);
NetworkWriterWriteInt16 = Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", int16Type);
NetworkWriterWriteInt32 = Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", int32Type);
NetworkWriterWriteInt16 = Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", int16Type);
NetworkReaderReadPacked32 = Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadPackedUInt32");
NetworkReaderReadPacked64 = Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadPackedUInt64");
NetworkReaderReadByte = Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadByte");
NetworkReaderReadPacked32 = Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadPackedUInt32");
NetworkReaderReadPacked64 = Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadPackedUInt64");
NetworkReaderReadByte = Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadByte");
NetworkWriterWritePacked32 = Resolvers.ResolveMethod(NetworkWriterType, scriptDef, "WritePackedUInt32");
NetworkWriterWritePacked64 = Resolvers.ResolveMethod(NetworkWriterType, scriptDef, "WritePackedUInt64");
NetworkWriterWritePacked32 = Resolvers.ResolveMethod(NetworkWriterType, CurrentAssembly, "WritePackedUInt32");
NetworkWriterWritePacked64 = Resolvers.ResolveMethod(NetworkWriterType, CurrentAssembly, "WritePackedUInt64");
NetworkReadUInt16 = Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadUInt16");
NetworkWriteUInt16 = Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", uint16Type);
NetworkReadUInt16 = Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadUInt16");
NetworkWriteUInt16 = Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", uint16Type);
CmdDelegateReference = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkBehaviour/CmdDelegate");
CmdDelegateConstructor = Resolvers.ResolveMethod(CmdDelegateReference, scriptDef, ".ctor");
scriptDef.MainModule.ImportReference(gameObjectType);
scriptDef.MainModule.ImportReference(transformType);
CmdDelegateReference = NetAssembly.MainModule.GetType("Mirror.NetworkBehaviour/CmdDelegate");
CmdDelegateConstructor = Resolvers.ResolveMethod(CmdDelegateReference, CurrentAssembly, ".ctor");
CurrentAssembly.MainModule.ImportReference(gameObjectType);
CurrentAssembly.MainModule.ImportReference(transformType);
TypeReference unetViewTmp = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkIdentity");
NetworkIdentityType = scriptDef.MainModule.ImportReference(unetViewTmp);
TypeReference netViewTmp = NetAssembly.MainModule.GetType("Mirror.NetworkIdentity");
NetworkIdentityType = CurrentAssembly.MainModule.ImportReference(netViewTmp);
NetworkBehaviourType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkBehaviour");
NetworkBehaviourType2 = scriptDef.MainModule.ImportReference(NetworkBehaviourType);
NetworkConnectionType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkConnection");
NetworkBehaviourType = NetAssembly.MainModule.GetType("Mirror.NetworkBehaviour");
NetworkBehaviourType2 = CurrentAssembly.MainModule.ImportReference(NetworkBehaviourType);
NetworkConnectionType = NetAssembly.MainModule.GetType("Mirror.NetworkConnection");
MonoBehaviourType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.MonoBehaviour");
ScriptableObjectType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.ScriptableObject");
MonoBehaviourType = UnityAssembly.MainModule.GetType("UnityEngine.MonoBehaviour");
ScriptableObjectType = UnityAssembly.MainModule.GetType("UnityEngine.ScriptableObject");
NetworkConnectionType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.NetworkConnection");
NetworkConnectionType = scriptDef.MainModule.ImportReference(NetworkConnectionType);
NetworkConnectionType = NetAssembly.MainModule.GetType("Mirror.NetworkConnection");
NetworkConnectionType = CurrentAssembly.MainModule.ImportReference(NetworkConnectionType);
ULocalConnectionToServerType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.ULocalConnectionToServer");
ULocalConnectionToServerType = scriptDef.MainModule.ImportReference(ULocalConnectionToServerType);
MessageBaseType = NetAssembly.MainModule.GetType("Mirror.MessageBase");
SyncListStructType = NetAssembly.MainModule.GetType("Mirror.SyncListSTRUCT`1");
ULocalConnectionToClientType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.ULocalConnectionToClient");
ULocalConnectionToClientType = scriptDef.MainModule.ImportReference(ULocalConnectionToClientType);
NetworkBehaviourDirtyBitsReference = Resolvers.ResolveProperty(NetworkBehaviourType, CurrentAssembly, "syncVarDirtyBits");
MessageBaseType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.MessageBase");
SyncListStructType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.SyncListSTRUCT`1");
NetworkBehaviourDirtyBitsReference = Resolvers.ResolveProperty(NetworkBehaviourType, scriptDef, "syncVarDirtyBits");
ComponentType = m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Component");
ClientSceneType = m_UNetAssemblyDefinition.MainModule.GetType("Mirror.ClientScene");
ReadyConnectionReference = Resolvers.ResolveMethod(ClientSceneType, scriptDef, "get_readyConnection");
ComponentType = UnityAssembly.MainModule.GetType("UnityEngine.Component");
ClientSceneType = NetAssembly.MainModule.GetType("Mirror.ClientScene");
ReadyConnectionReference = Resolvers.ResolveMethod(ClientSceneType, CurrentAssembly, "get_readyConnection");
// get specialized GetComponent<NetworkIdentity>()
getComponentReference = Resolvers.ResolveMethodGeneric(ComponentType, scriptDef, "GetComponent", NetworkIdentityType);
getComponentReference = Resolvers.ResolveMethodGeneric(ComponentType, CurrentAssembly, "GetComponent", NetworkIdentityType);
getUNetIdReference = Resolvers.ResolveMethod(unetViewTmp, scriptDef, "get_netId");
getNetIdReference = Resolvers.ResolveMethod(netViewTmp, CurrentAssembly, "get_netId");
gameObjectInequality = Resolvers.ResolveMethod(unityObjectType, scriptDef, "op_Inequality");
gameObjectInequality = Resolvers.ResolveMethod(unityObjectType, CurrentAssembly, "op_Inequality");
UBehaviourIsServer = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "get_isServer");
setSyncVarReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SetSyncVar");
setSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "set_syncVarHookGuard");
getSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "get_syncVarHookGuard");
UBehaviourIsServer = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "get_isServer");
setSyncVarReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SetSyncVar");
setSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "set_syncVarHookGuard");
getSyncVarHookGuard = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "get_syncVarHookGuard");
setSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SetSyncVarGameObject");
getSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "GetSyncVarGameObject");
setSyncVarNetworkIdentityReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SetSyncVarNetworkIdentity");
getSyncVarNetworkIdentityReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "GetSyncVarNetworkIdentity");
registerCommandDelegateReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "RegisterCommandDelegate");
registerRpcDelegateReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "RegisterRpcDelegate");
registerEventDelegateReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "RegisterEventDelegate");
getTypeReference = Resolvers.ResolveMethod(objectType, scriptDef, "GetType");
getTypeFromHandleReference = Resolvers.ResolveMethod(typeType, scriptDef, "GetTypeFromHandle");
logErrorReference = Resolvers.ResolveMethod(m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Debug"), scriptDef, "LogError");
logWarningReference = Resolvers.ResolveMethod(m_UnityAssemblyDefinition.MainModule.GetType("UnityEngine.Debug"), scriptDef, "LogWarning");
sendCommandInternal = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SendCommandInternal");
sendRpcInternal = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SendRPCInternal");
sendTargetRpcInternal = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SendTargetRPCInternal");
sendEventInternal = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "SendEventInternal");
setSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SetSyncVarGameObject");
getSyncVarGameObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "GetSyncVarGameObject");
setSyncVarNetworkIdentityReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SetSyncVarNetworkIdentity");
getSyncVarNetworkIdentityReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "GetSyncVarNetworkIdentity");
registerCommandDelegateReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "RegisterCommandDelegate");
registerRpcDelegateReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "RegisterRpcDelegate");
registerEventDelegateReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "RegisterEventDelegate");
getTypeReference = Resolvers.ResolveMethod(objectType, CurrentAssembly, "GetType");
getTypeFromHandleReference = Resolvers.ResolveMethod(typeType, CurrentAssembly, "GetTypeFromHandle");
logErrorReference = Resolvers.ResolveMethod(UnityAssembly.MainModule.GetType("UnityEngine.Debug"), CurrentAssembly, "LogError");
logWarningReference = Resolvers.ResolveMethod(UnityAssembly.MainModule.GetType("UnityEngine.Debug"), CurrentAssembly, "LogWarning");
sendCommandInternal = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SendCommandInternal");
sendRpcInternal = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SendRPCInternal");
sendTargetRpcInternal = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SendTargetRPCInternal");
sendEventInternal = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "SendEventInternal");
SyncObjectType = scriptDef.MainModule.ImportReference(SyncObjectType);
InitSyncObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, scriptDef, "InitSyncObject");
SyncObjectType = CurrentAssembly.MainModule.ImportReference(SyncObjectType);
InitSyncObjectReference = Resolvers.ResolveMethod(NetworkBehaviourType, CurrentAssembly, "InitSyncObject");
}
static void SetupReadFunctions()
{
lists.readFuncs = new Dictionary<string, MethodReference>
WeaveLists.readFuncs = new Dictionary<string, MethodReference>
{
{ singleType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadSingle") },
{ doubleType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadDouble") },
{ boolType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadBoolean") },
{ stringType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadString") },
{ singleType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadSingle") },
{ doubleType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadDouble") },
{ boolType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadBoolean") },
{ stringType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadString") },
{ int64Type.FullName, NetworkReaderReadPacked64 },
{ uint64Type.FullName, NetworkReaderReadPacked64 },
{ int32Type.FullName, NetworkReaderReadPacked32 },
@ -1187,33 +1181,33 @@ static void SetupReadFunctions()
{ byteType.FullName, NetworkReaderReadPacked32 },
{ sbyteType.FullName, NetworkReaderReadPacked32 },
{ charType.FullName, NetworkReaderReadPacked32 },
{ decimalType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadDecimal") },
{ vector2Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadVector2") },
{ vector3Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadVector3") },
{ vector4Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadVector4") },
{ colorType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadColor") },
{ color32Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadColor32") },
{ quaternionType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadQuaternion") },
{ rectType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadRect") },
{ planeType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadPlane") },
{ rayType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadRay") },
{ matrixType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadMatrix4x4") },
{ guidType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadGuid") },
{ gameObjectType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadGameObject") },
{ NetworkIdentityType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadNetworkIdentity") },
{ transformType.FullName, Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadTransform") },
{ "System.Byte[]", Resolvers.ResolveMethod(NetworkReaderType, scriptDef, "ReadBytesAndSize") },
{ decimalType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadDecimal") },
{ vector2Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadVector2") },
{ vector3Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadVector3") },
{ vector4Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadVector4") },
{ colorType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadColor") },
{ color32Type.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadColor32") },
{ quaternionType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadQuaternion") },
{ rectType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadRect") },
{ planeType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadPlane") },
{ rayType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadRay") },
{ matrixType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadMatrix4x4") },
{ guidType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadGuid") },
{ gameObjectType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadGameObject") },
{ NetworkIdentityType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadNetworkIdentity") },
{ transformType.FullName, Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadTransform") },
{ "System.Byte[]", Resolvers.ResolveMethod(NetworkReaderType, CurrentAssembly, "ReadBytesAndSize") },
};
}
static void SetupWriteFunctions()
{
lists.writeFuncs = new Dictionary<string, MethodReference>
WeaveLists.writeFuncs = new Dictionary<string, MethodReference>
{
{ singleType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", singleType) },
{ doubleType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", doubleType) },
{ boolType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", boolType) },
{ stringType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", stringType) },
{ singleType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", singleType) },
{ doubleType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", doubleType) },
{ boolType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", boolType) },
{ stringType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", stringType) },
{ int64Type.FullName, NetworkWriterWritePacked64 },
{ uint64Type.FullName, NetworkWriterWritePacked64 },
{ int32Type.FullName, NetworkWriterWritePacked32 },
@ -1223,22 +1217,22 @@ static void SetupWriteFunctions()
{ byteType.FullName, NetworkWriterWritePacked32 },
{ sbyteType.FullName, NetworkWriterWritePacked32 },
{ charType.FullName, NetworkWriterWritePacked32 },
{ decimalType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", decimalType) },
{ vector2Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", vector2Type) },
{ vector3Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", vector3Type) },
{ vector4Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", vector4Type) },
{ colorType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", colorType) },
{ color32Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", color32Type) },
{ quaternionType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", quaternionType) },
{ rectType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", rectType) },
{ planeType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", planeType) },
{ rayType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", rayType) },
{ matrixType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", matrixType) },
{ guidType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", guidType) },
{ gameObjectType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", gameObjectType) },
{ NetworkIdentityType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", NetworkIdentityType) },
{ transformType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "Write", transformType) },
{ "System.Byte[]", Resolvers.ResolveMethodWithArg(NetworkWriterType, scriptDef, "WriteBytesAndSize", "System.Byte[]") }
{ decimalType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", decimalType) },
{ vector2Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", vector2Type) },
{ vector3Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", vector3Type) },
{ vector4Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", vector4Type) },
{ colorType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", colorType) },
{ color32Type.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", color32Type) },
{ quaternionType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", quaternionType) },
{ rectType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", rectType) },
{ planeType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", planeType) },
{ rayType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", rayType) },
{ matrixType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", matrixType) },
{ guidType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", guidType) },
{ gameObjectType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", gameObjectType) },
{ NetworkIdentityType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", NetworkIdentityType) },
{ transformType.FullName, Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "Write", transformType) },
{ "System.Byte[]", Resolvers.ResolveMethodWithArg(NetworkWriterType, CurrentAssembly, "WriteBytesAndSize", "System.Byte[]") }
};
}
@ -1252,14 +1246,13 @@ public static bool IsValidTypeToGenerate(TypeDefinition variable)
// a valid type is a simple class or struct. so we generate only code for types we dont know, and if they are not inside
// this assembly it must mean that we are trying to serialize a variable outside our scope. and this will fail.
string assembly = scriptDef.MainModule.Name;
string assembly = CurrentAssembly.MainModule.Name;
if (variable.Module.Name != assembly)
{
Log.Error("parameter [" + variable.Name +
Weaver.Error("parameter [" + variable.Name +
"] is of the type [" +
variable.FullName +
"] is not a valid type, please make sure to use a valid type.");
fail = true;
return false;
}
return true;
@ -1392,16 +1385,18 @@ static bool CheckSyncListStruct(TypeDefinition td)
return didWork;
}
static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyResolver assemblyResolver, string unityEngineDLLPath, string unityUNetDLLPath, string outputDir)
static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyResolver assemblyResolver, string unityEngineDLLPath, string mirrorNetDLLPath, string outputDir)
{
ReaderParameters readParams = Helpers.ReaderParameters(assName, dependencies, assemblyResolver, unityEngineDLLPath, unityUNetDLLPath);
scriptDef = AssemblyDefinition.ReadAssembly(assName, readParams);
ReaderParameters readParams = Helpers.ReaderParameters(assName, dependencies, assemblyResolver, unityEngineDLLPath, mirrorNetDLLPath);
string pdbToDelete = null;
using (CurrentAssembly = AssemblyDefinition.ReadAssembly(assName, readParams))
{
SetupTargetTypes();
SetupReadFunctions();
SetupWriteFunctions();
ModuleDefinition moduleDefinition = scriptDef.MainModule;
ModuleDefinition moduleDefinition = CurrentAssembly.MainModule;
Console.WriteLine("Script Module: {0}", moduleDefinition.Name);
// Process each NetworkBehaviour
@ -1429,17 +1424,17 @@ static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyRes
}
catch (Exception ex)
{
if (scriptDef.MainModule.SymbolReader != null)
scriptDef.MainModule.SymbolReader.Dispose();
fail = true;
if (CurrentAssembly.MainModule.SymbolReader != null)
CurrentAssembly.MainModule.SymbolReader.Dispose();
Weaver.Error(ex.Message);
throw ex;
}
}
if (fail)
if (WeavingFailed)
{
if (scriptDef.MainModule.SymbolReader != null)
scriptDef.MainModule.SymbolReader.Dispose();
if (CurrentAssembly.MainModule.SymbolReader != null)
CurrentAssembly.MainModule.SymbolReader.Dispose();
return false;
}
}
@ -1457,16 +1452,16 @@ static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyRes
catch (Exception e)
{
Log.Error("ProcessPropertySites exception: " + e);
if (scriptDef.MainModule.SymbolReader != null)
scriptDef.MainModule.SymbolReader.Dispose();
if (CurrentAssembly.MainModule.SymbolReader != null)
CurrentAssembly.MainModule.SymbolReader.Dispose();
return false;
}
if (fail)
if (WeavingFailed)
{
//Log.Error("Failed phase II.");
if (scriptDef.MainModule.SymbolReader != null)
scriptDef.MainModule.SymbolReader.Dispose();
if (CurrentAssembly.MainModule.SymbolReader != null)
CurrentAssembly.MainModule.SymbolReader.Dispose();
return false;
}
@ -1474,6 +1469,7 @@ static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyRes
//Console.WriteLine ("Output:" + dest);
WriterParameters writeParams = Helpers.GetWriterParameters(readParams);
CurrentAssembly.Write(dest, writeParams);
// PdbWriterProvider uses ISymUnmanagedWriter2 COM interface but Mono can't invoke a method on it and crashes (actually it first throws the following exception and then crashes).
// One solution would be to convert UNetWeaver to exe file and run it on .NET on Windows (I have tested that and it works).
@ -1485,35 +1481,27 @@ static bool Weave(string assName, IEnumerable<string> dependencies, IAssemblyRes
{
writeParams.SymbolWriterProvider = new MdbWriterProvider();
// old pdb file is out of date so delete it. symbols will be stored in mdb
string pdb = Path.ChangeExtension(assName, ".pdb");
try
{
File.Delete(pdb);
}
catch (Exception ex)
{
// workaround until Unity fixes C#7 compiler compability with the UNET weaver
UnityEngine.Debug.LogWarning(string.Format("Unable to delete file {0}: {1}", pdb, ex.Message));
pdbToDelete = Path.ChangeExtension(assName, ".pdb");
}
}
scriptDef.Write(dest, writeParams);
if (CurrentAssembly.MainModule.SymbolReader != null)
CurrentAssembly.MainModule.SymbolReader.Dispose();
}
if (scriptDef.MainModule.SymbolReader != null)
scriptDef.MainModule.SymbolReader.Dispose();
if (pdbToDelete != null)
File.Delete(pdbToDelete);
return true;
}
public static bool WeaveAssemblies(IEnumerable<string> assemblies, IEnumerable<string> dependencies, IAssemblyResolver assemblyResolver, string outputDir, string unityEngineDLLPath, string unityUNetDLLPath)
public static bool WeaveAssemblies(IEnumerable<string> assemblies, IEnumerable<string> dependencies, IAssemblyResolver assemblyResolver, string outputDir, string unityEngineDLLPath, string mirrorNetDLLPath)
{
fail = false;
lists = new WeaverLists();
WeavingFailed = false;
WeaveLists = new WeaverLists();
m_UnityAssemblyDefinition = AssemblyDefinition.ReadAssembly(unityEngineDLLPath);
m_UNetAssemblyDefinition = AssemblyDefinition.ReadAssembly(unityUNetDLLPath);
UnityAssembly = AssemblyDefinition.ReadAssembly(unityEngineDLLPath);
NetAssembly = AssemblyDefinition.ReadAssembly(mirrorNetDLLPath);
SetupUnityTypes();
@ -1521,7 +1509,7 @@ public static bool WeaveAssemblies(IEnumerable<string> assemblies, IEnumerable<s
{
foreach (string ass in assemblies)
{
if (!Weave(ass, dependencies, assemblyResolver, unityEngineDLLPath, unityUNetDLLPath, outputDir))
if (!Weave(ass, dependencies, assemblyResolver, unityEngineDLLPath, mirrorNetDLLPath, outputDir))
{
return false;
}
@ -1532,7 +1520,7 @@ public static bool WeaveAssemblies(IEnumerable<string> assemblies, IEnumerable<s
Log.Error("Exception :" + e);
return false;
}
corLib = null;
CorLibModule = null;
return true;
}
}

View File

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

View File

@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mirror;
namespace Mirror.Examples.Basic
{
@ -18,7 +15,7 @@ public class Player : NetworkBehaviour
public override void OnStartServer()
{
base.OnStartServer();
InvokeRepeating("UpdateData", 1, 1);
InvokeRepeating(nameof(UpdateData), 1, 1);
}
public void UpdateData()
@ -31,7 +28,7 @@ public void Update()
if (isLocalPlayer)
text.color = Color.red;
text.text = string.Format("Player {0}\ndata={1}", netId, data);
text.text = $"Player {netId}\ndata={data}";
}
}
}

View File

@ -1,6 +1,6 @@
# Lobby Example
In Buld Settings, remove all scenes and add all of the scenes from the Examples\Lobbey\Scenes folder in the following order:
In Build Settings, remove all scenes and add all of the scenes from the Examples\Lobby\Scenes folder in the following order:
- Offline
- Lobby

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.1802836, g: 0.22571391, b: 0.3069226, a: 1}
m_IndirectSpecularColor: {r: 0.4616949, g: 0.5124162, b: 0.5899328, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -50,7 +50,6 @@ LightmapSettings:
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 1
@ -118,7 +117,8 @@ NavMeshSettings:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 29930035}
@ -135,22 +135,24 @@ GameObject:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 29930032}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SceneId: 0
m_ServerOnly: 1
m_LocalPlayerAuthority: 0
m_AssetId:
m_SceneId: 6047645
--- !u!114 &29930034
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 29930032}
m_Enabled: 1
m_EditorHideFlags: 0
@ -159,12 +161,13 @@ MonoBehaviour:
m_EditorClassIdentifier:
syncInterval: 0.1
prizePrefab: {fileID: 114251241889735402, guid: 52f1c9ea06cfd154cb68ff9d1b66fc13,
type: 2}
type: 3}
--- !u!4 &29930035
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 29930032}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
@ -177,7 +180,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 151116942}
@ -193,7 +197,8 @@ GameObject:
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 151116940}
m_Enabled: 1
serializedVersion: 8
@ -230,7 +235,8 @@ Light:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 151116940}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 10, z: 0}
@ -243,7 +249,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 204334130}
@ -259,7 +266,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 204334129}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -15}
@ -272,7 +280,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 204334129}
m_Enabled: 1
m_EditorHideFlags: 0
@ -283,7 +292,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 263230755}
@ -299,7 +309,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 263230754}
m_LocalRotation: {x: 0, y: 0.38268343, z: 0, w: 0.92387956}
m_LocalPosition: {x: -15, y: 0, z: -15}
@ -312,7 +323,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 263230754}
m_Enabled: 1
m_EditorHideFlags: 0
@ -323,7 +335,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 290557150}
@ -339,7 +352,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 290557149}
m_LocalRotation: {x: 0, y: 0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: -15, y: 0, z: 0}
@ -352,7 +366,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 290557149}
m_Enabled: 1
m_EditorHideFlags: 0
@ -363,7 +378,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 733367780}
@ -379,7 +395,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 733367779}
m_LocalRotation: {x: -0, y: 1, z: -0, w: 0}
m_LocalPosition: {x: 0, y: 0, z: 15}
@ -392,7 +409,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 733367779}
m_Enabled: 1
m_EditorHideFlags: 0
@ -403,7 +421,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 990635330}
@ -419,7 +438,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 990635329}
m_LocalRotation: {x: 0, y: 0.92387956, z: 0, w: 0.38268343}
m_LocalPosition: {x: -15, y: 0, z: 15}
@ -432,7 +452,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 990635329}
m_Enabled: 1
m_EditorHideFlags: 0
@ -443,7 +464,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1050066545}
@ -460,14 +482,16 @@ GameObject:
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1050066542}
m_Enabled: 1
--- !u!20 &1050066544
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1050066542}
m_Enabled: 1
serializedVersion: 2
@ -476,6 +500,7 @@ Camera:
m_projectionMatrixMode: 1
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
m_GateFitMode: 2
m_FocalLength: 50
m_NormalizedViewPortRect:
serializedVersion: 2
@ -507,7 +532,8 @@ Camera:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1050066542}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 2, z: -10}
@ -520,7 +546,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1305256745}
@ -542,7 +569,8 @@ GameObject:
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Material: {fileID: 0}
m_IsTrigger: 0
@ -554,7 +582,8 @@ BoxCollider:
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Material: {fileID: 0}
m_IsTrigger: 0
@ -566,7 +595,8 @@ BoxCollider:
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Material: {fileID: 0}
m_IsTrigger: 0
@ -578,7 +608,8 @@ BoxCollider:
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Material: {fileID: 0}
m_IsTrigger: 0
@ -590,7 +621,8 @@ BoxCollider:
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Enabled: 1
m_CastShadows: 1
@ -600,6 +632,7 @@ MeshRenderer:
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: 3201636fa507dad448e9a36d66a80825, type: 2}
m_StaticBatchInfo:
@ -625,7 +658,8 @@ MeshRenderer:
MeshCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Material: {fileID: 0}
m_IsTrigger: 0
@ -633,20 +667,21 @@ MeshCollider:
serializedVersion: 3
m_Convex: 0
m_CookingOptions: 14
m_SkinWidth: 0.01
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!33 &1305256744
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1305256745
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1305256737}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
@ -659,7 +694,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1445635740}
@ -674,7 +710,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1445635739}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1.08, z: 0}
@ -695,7 +732,8 @@ Transform:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1760045337}
@ -711,7 +749,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1760045336}
m_LocalRotation: {x: 0, y: 0.3826836, z: -0, w: -0.92387944}
m_LocalPosition: {x: 15, y: 0, z: -15}
@ -724,7 +763,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1760045336}
m_Enabled: 1
m_EditorHideFlags: 0
@ -735,7 +775,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1975674813}
@ -751,7 +792,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1975674812}
m_LocalRotation: {x: 0, y: 0.7071068, z: -0, w: -0.7071068}
m_LocalPosition: {x: 15, y: 0, z: 0}
@ -764,7 +806,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1975674812}
m_Enabled: 1
m_EditorHideFlags: 0
@ -775,7 +818,8 @@ MonoBehaviour:
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2127619492}
@ -791,7 +835,8 @@ GameObject:
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2127619491}
m_LocalRotation: {x: 0, y: 0.9238796, z: -0, w: -0.38268325}
m_LocalPosition: {x: 15, y: 0, z: 15}
@ -804,7 +849,8 @@ Transform:
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2127619491}
m_Enabled: 1
m_EditorHideFlags: 0

View File

@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.Rendering;
namespace Mirror.Examples.NetworkLobby

View File

@ -1,5 +1,4 @@
using UnityEngine;
using Mirror;
using UnityEngine.SceneManagement;
namespace Mirror.Examples.NetworkLobby
@ -28,12 +27,6 @@ in ServerChangeScene and OnClientChangeScene.
gameObject.transform.SetParent(GameObject.Find("Players").transform);
}
public override void ClientLoadedScene(Scene arg0, LoadSceneMode arg1)
{
NetworkLobbyManager lobby = NetworkManager.singleton as NetworkLobbyManager;
base.ClientLoadedScene(arg0, arg1);
}
public override void OnClientEnterLobby()
{
if (LogFilter.Debug) Debug.LogFormat("OnClientEnterLobby {0}", SceneManager.GetActiveScene().name);

View File

@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
namespace Mirror.Examples.NetworkLobby
{
@ -70,7 +70,7 @@ void FixedUpdate()
{
if (!isLocalPlayer || characterController == null) return;
transform.Rotate(0f, turn * Time.deltaTime, 0f);
transform.Rotate(0f, turn * Time.fixedDeltaTime, 0f);
direction = transform.TransformDirection((Vector3.ClampMagnitude(new Vector3(horiz, 0f, vert), 1f) * moveSpeed));
characterController.SimpleMove(direction * Time.fixedDeltaTime);

View File

@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
namespace Mirror.Examples.NetworkLobby
{

View File

@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
namespace Mirror.Examples.NetworkLobby
{

View File

@ -1,216 +0,0 @@
fileFormatVersion: 2
guid: 88b1ead8370bd4ea1806795824f0551d
ModelImporter:
serializedVersion: 22
fileIDToRecycleName:
100000: Body
100002: Bot.Armature
100004: Bot.Mesh
100006: CameraTarget
100008: Cannon.L
100010: Cannon.L_end
100012: Cannon.R
100014: Cannon.R_end
100016: Eye
100018: Eye.Spacer
100020: Eye_end
100022: Leg.1.Front.FK.L
100024: Leg.1.Front.FK.R
100026: Leg.1.Front.IK.L
100028: Leg.1.Front.IK.R
100030: Leg.1.Rear.FK.L
100032: Leg.1.Rear.FK.R
100034: Leg.1.Rear.IK.L
100036: Leg.1.Rear.IK.R
100038: Leg.2.Front.FK.L
100040: Leg.2.Front.FK.R
100042: Leg.2.Front.IK.L
100044: Leg.2.Front.IK.R
100046: Leg.2.Rear.FK.L
100048: Leg.2.Rear.FK.R
100050: Leg.2.Rear.IK.L
100052: Leg.2.Rear.IK.R
100054: Leg.3.Front.FK.L
100056: Leg.3.Front.FK.L_end
100058: Leg.3.Front.FK.R
100060: Leg.3.Front.FK.R_end
100062: Leg.3.Front.IK.L
100064: Leg.3.Front.IK.L_end
100066: Leg.3.Front.IK.R
100068: Leg.3.Front.IK.R_end
100070: Leg.3.Rear.FK.L
100072: Leg.3.Rear.FK.L_end
100074: Leg.3.Rear.FK.R
100076: Leg.3.Rear.FK.R_end
100078: Leg.3.Rear.IK.L
100080: Leg.3.Rear.IK.L_end
100082: Leg.3.Rear.IK.R
100084: Leg.3.Rear.IK.R_end
100086: //RootNode
100088: Root
100090: Switch.IKFK.Front.L
100092: Switch.IKFK.Front.L_end
100094: Switch.IKFK.Front.R
100096: Switch.IKFK.Front.R_end
100098: Switch.IKFK.Rear.L
100100: Switch.IKFK.Rear.L_end
100102: Switch.IKFK.Rear.R
100104: Switch.IKFK.Rear.R_end
100106: Target.Leg.3.Front.IK.L
100108: Target.Leg.3.Front.IK.L_end
100110: Target.Leg.3.Front.IK.R
100112: Target.Leg.3.Front.IK.R_end
100114: Target.Leg.3.Rear.IK.L
100116: Target.Leg.3.Rear.IK.L_end
100118: Target.Leg.3.Rear.IK.R
100120: Target.Leg.3.Rear.IK.R_end
100122: WID.Arrow
400000: Body
400002: Bot.Armature
400004: Bot.Mesh
400006: CameraTarget
400008: Cannon.L
400010: Cannon.L_end
400012: Cannon.R
400014: Cannon.R_end
400016: Eye
400018: Eye.Spacer
400020: Eye_end
400022: Leg.1.Front.FK.L
400024: Leg.1.Front.FK.R
400026: Leg.1.Front.IK.L
400028: Leg.1.Front.IK.R
400030: Leg.1.Rear.FK.L
400032: Leg.1.Rear.FK.R
400034: Leg.1.Rear.IK.L
400036: Leg.1.Rear.IK.R
400038: Leg.2.Front.FK.L
400040: Leg.2.Front.FK.R
400042: Leg.2.Front.IK.L
400044: Leg.2.Front.IK.R
400046: Leg.2.Rear.FK.L
400048: Leg.2.Rear.FK.R
400050: Leg.2.Rear.IK.L
400052: Leg.2.Rear.IK.R
400054: Leg.3.Front.FK.L
400056: Leg.3.Front.FK.L_end
400058: Leg.3.Front.FK.R
400060: Leg.3.Front.FK.R_end
400062: Leg.3.Front.IK.L
400064: Leg.3.Front.IK.L_end
400066: Leg.3.Front.IK.R
400068: Leg.3.Front.IK.R_end
400070: Leg.3.Rear.FK.L
400072: Leg.3.Rear.FK.L_end
400074: Leg.3.Rear.FK.R
400076: Leg.3.Rear.FK.R_end
400078: Leg.3.Rear.IK.L
400080: Leg.3.Rear.IK.L_end
400082: Leg.3.Rear.IK.R
400084: Leg.3.Rear.IK.R_end
400086: //RootNode
400088: Root
400090: Switch.IKFK.Front.L
400092: Switch.IKFK.Front.L_end
400094: Switch.IKFK.Front.R
400096: Switch.IKFK.Front.R_end
400098: Switch.IKFK.Rear.L
400100: Switch.IKFK.Rear.L_end
400102: Switch.IKFK.Rear.R
400104: Switch.IKFK.Rear.R_end
400106: Target.Leg.3.Front.IK.L
400108: Target.Leg.3.Front.IK.L_end
400110: Target.Leg.3.Front.IK.R
400112: Target.Leg.3.Front.IK.R_end
400114: Target.Leg.3.Rear.IK.L
400116: Target.Leg.3.Rear.IK.L_end
400118: Target.Leg.3.Rear.IK.R
400120: Target.Leg.3.Rear.IK.R_end
400122: WID.Arrow
2100000: Bot
2300000: WID.Arrow
3300000: WID.Arrow
4300000: Bot.Mesh
4300002: WID.Arrow
9500000: //RootNode
13700000: Bot.Mesh
externalObjects: {}
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations: []
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 0.33
meshCompression: 0
addColliders: 0
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 1
normalCalculationMode: 4
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1}
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 KiB

View File

@ -1,31 +0,0 @@
BA-2 (Blast All Bot Mark 2)
By: Quandtum
License: CC-0
Blender Version: 2.66a, r55057
Model Version: 1.1
3D preview available @ http://p3d.in/i67jh
What is included:
1 x BA-2 base mesh (3380 vertices, 6964 Edges, 3616 faces, 6696 Tris, UV unwrapped)
1 x Diffuse map (2048 x 2048)
1 x Normal map (2048 x 2048)
1 x Bump map (2048 x 2048)
1 x Specular map (2048 x 2048)
1 x Emission map (2048 x 2048)
1 x Animation armature
Complete model is not manifold, but rather a composition of manifold "parts". Each part is manifold and all parts were combined into a single mesh named "Bot.Mesh".
Maps included are all large 2048 x 2048. Reason is they can be reduced but not grown, resize them to fit as needed.
Texture samples sourced from:
http://www.plaintextures.com/
http://www.goodtextures.com/
Textures were otherwise hand painted.
There is admittingly an error in the bump/normal mapping in the emission areas. They are not very noticable, and with the emission map enabled they are concealed.
Revision History:
Version 1.0 - 01/21/2013; Initial release.
Version 1.1 - Sat Mar 23 14:36:46 CDT 2013; Updated branding.

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
using UnityEngine;
using Mirror;
namespace Mirror.Examples.Movement
{
public class Move : NetworkBehaviour
{
public CharacterController controller;
public float speed = 300;
public float rotationSpeed = 400;
void Update()
{
// movement for local player
if (!isLocalPlayer) return;
// rotate
transform.Rotate(0, Input.GetAxis("Horizontal") * rotationSpeed * Time.deltaTime, 0);
// move
Vector3 forward = transform.TransformDirection(Vector3.forward);
controller.SimpleMove(forward * Input.GetAxis("Vertical") * speed * Time.deltaTime);
}
}
}

View File

@ -1,22 +1,12 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1240244544407914}
m_IsPrefabParent: 1
--- !u!1 &1240244544407914
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4118252415362944}
- component: {fileID: 212641192162007874}
@ -34,9 +24,10 @@ GameObject:
m_IsActive: 1
--- !u!4 &4118252415362944
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
@ -45,97 +36,12 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &50389918509199184
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1240244544407914}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 1
m_Constraints: 4
--- !u!61 &61279767645666242
BoxCollider2D:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 2, y: 4}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 2, y: 4}
m_EdgeRadius: 0
--- !u!114 &114104497298166850
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SceneId: 0
m_ServerOnly: 0
m_LocalPlayerAuthority: 1
m_AssetId: b1651eaf8c7564a1c86031dfbb8a7b28
--- !u!114 &114398896143473162
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2f74aedd71d9a4f55b3ce499326d45fb, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
compressRotation: 1
--- !u!114 &114626868563338794
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0748c7eda22b19845b9ce0e4d23d1021, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
speed: 30
--- !u!212 &212641192162007874
SpriteRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_CastShadows: 0
@ -144,6 +50,8 @@ SpriteRenderer:
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
@ -175,3 +83,95 @@ SpriteRenderer:
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!61 &61279767645666242
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 2, y: 4}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 2, y: 4}
m_EdgeRadius: 0
--- !u!50 &50389918509199184
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 0
m_Mass: 1
m_LinearDrag: 0
m_AngularDrag: 0.05
m_GravityScale: 0
m_Material: {fileID: 0}
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 1
m_Constraints: 4
--- !u!114 &114104497298166850
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ServerOnly: 0
m_LocalPlayerAuthority: 1
m_AssetId: b1651eaf8c7564a1c86031dfbb8a7b28
m_SceneId: 0
--- !u!114 &114626868563338794
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0748c7eda22b19845b9ce0e4d23d1021, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
speed: 1500
--- !u!114 &114398896143473162
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1240244544407914}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2f74aedd71d9a4f55b3ce499326d45fb, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
compressRotation: 1

View File

@ -200,7 +200,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 473997961}
- component: {fileID: 473997960}
m_Layer: 0
m_Name: RacketSpawnLeft
m_TagString: Untagged
@ -208,18 +207,6 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &473997960
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 473997959}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &473997961
Transform:
m_ObjectHideFlags: 0
@ -232,7 +219,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &753891880
GameObject:
@ -340,52 +327,6 @@ BoxCollider2D:
serializedVersion: 2
m_Size: {x: 50, y: 1}
m_EdgeRadius: 0
--- !u!1001 &1140775523
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalPosition.x
value: -3
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4700925592147096, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
propertyPath: m_RootOrder
value: 3
objectReference: {fileID: 0}
- target: {fileID: 50354248948880112, guid: 5f7a7f34494ed40268eff49dbf9168bf,
type: 3}
propertyPath: m_Simulated
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
--- !u!1 &1346799726
GameObject:
m_ObjectHideFlags: 0
@ -707,7 +648,6 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1397990096}
- component: {fileID: 1397990095}
m_Layer: 0
m_Name: RacketSpawnRight
m_TagString: Untagged
@ -715,18 +655,6 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1397990095
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1397990094}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41f84591ce72545258ea98cb7518d8b9, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1397990096
Transform:
m_ObjectHideFlags: 0
@ -739,7 +667,7 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1575697329
GameObject:
@ -939,7 +867,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1886246549}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8aab4c8111b7c411b9b92cf3dbc5bd4e, type: 3}
m_Script: {fileID: 11500000, guid: 0aa3018bb284840d6a6d0acee29ab098, type: 3}
m_Name:
m_EditorClassIdentifier:
dontDestroyOnLoad: 1
@ -956,7 +884,12 @@ MonoBehaviour:
type: 3}
autoCreatePlayer: 1
playerSpawnMethod: 1
spawnPrefabs: []
spawnPrefabs:
- {fileID: 1080679924113744, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
leftRacketSpawn: {fileID: 473997961}
rightRacketSpawn: {fileID: 1397990096}
ballPrefab: {fileID: 1080679924113744, guid: 5f7a7f34494ed40268eff49dbf9168bf, type: 3}
ball: {fileID: 0}
--- !u!114 &1886246553
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -1,5 +1,4 @@
using UnityEngine;
using Mirror;
using UnityEngine;
namespace Mirror.Examples.Pong
{
@ -11,8 +10,6 @@ public override void OnStartServer()
{
// only simulate ball physics on server
GetComponent<Rigidbody2D>().simulated = true;
// Initial Velocity
GetComponent<Rigidbody2D>().velocity = Vector2.right * speed;
}

View File

@ -0,0 +1,38 @@
// custom NetworkManager that simply assigns the correct racket positions when
// spawning players. the built in RoundRobin spawn method wouldn't work after
// someone reconnects (both players would be on the same side).
using UnityEngine;
using Mirror;
public class NetworkManagerPong : NetworkManager
{
public Transform leftRacketSpawn;
public Transform rightRacketSpawn;
public GameObject ballPrefab;
GameObject ball;
public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
{
// add player at correct spawn position
Transform start = numPlayers == 0 ? leftRacketSpawn : rightRacketSpawn;
GameObject player = Instantiate(playerPrefab, start.position, start.rotation);
NetworkServer.AddPlayerForConnection(conn, player);
// spawn ball if two players
if (numPlayers == 2)
{
ball = Instantiate(ballPrefab);
NetworkServer.Spawn(ball);
}
}
public override void OnServerDisconnect(NetworkConnection conn)
{
// destroy ball
if (ball != null)
NetworkServer.Destroy(ball);
// call base functionality (actually destroys the player)
base.OnServerDisconnect(conn);
}
}

View File

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

View File

@ -1,5 +1,4 @@
using UnityEngine;
using Mirror;
using UnityEngine;
namespace Mirror.Examples.Pong
{
@ -15,7 +14,7 @@ void FixedUpdate()
if (!isLocalPlayer) return;
float vertical = Input.GetAxisRaw("Vertical");
GetComponent<Rigidbody2D>().velocity = new Vector2(0, vertical) * speed;
GetComponent<Rigidbody2D>().velocity = new Vector2(0, vertical) * speed * Time.fixedDeltaTime;
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d8b3e43538fc240feb28e07816c7e733
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 918 KiB

View File

@ -1,12 +1,12 @@
fileFormatVersion: 2
guid: 029d4d06af6a74673b65859a0a3af0f6
guid: ce00d67f9368944fa8ef4de6ccc77bfa
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 4
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@ -21,6 +21,8 @@ TextureImporter:
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -31,14 +33,14 @@ TextureImporter:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@ -47,15 +49,17 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 8
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
@ -70,7 +74,15 @@ TextureImporter:
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,272 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!91 &9100000
AnimatorController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Controller
serializedVersion: 5
m_AnimatorParameters:
- m_Name: Moving
m_Type: 4
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
- m_Name: Shoot
m_Type: 9
m_DefaultFloat: 0
m_DefaultInt: 0
m_DefaultBool: 0
m_Controller: {fileID: 0}
m_AnimatorLayers:
- serializedVersion: 5
m_Name: Base Layer
m_StateMachine: {fileID: 1107772262116321704}
m_Mask: {fileID: 0}
m_Motions: []
m_Behaviours: []
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &1101104249963802978
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Moving
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102824315819425342}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.6
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101366829127142966
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Shoot
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102254808008813326}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0
m_TransitionOffset: 0
m_ExitTime: 1
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101806660142692138
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: Moving
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102207974245764242}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.6
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101862483397811748
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 2
m_ConditionEvent: Moving
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102207974245764242}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1101 &1101947542735704306
AnimatorStateTransition:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_Conditions:
- m_ConditionMode: 1
m_ConditionEvent: Moving
m_EventTreshold: 0
m_DstStateMachine: {fileID: 0}
m_DstState: {fileID: 1102824315819425342}
m_Solo: 0
m_Mute: 0
m_IsExit: 0
serializedVersion: 3
m_TransitionDuration: 0.25
m_TransitionOffset: 0
m_ExitTime: 0.75
m_HasExitTime: 0
m_HasFixedDuration: 1
m_InterruptionSource: 0
m_OrderedInterruption: 1
m_CanTransitionToSelf: 1
--- !u!1102 &1102207974245764242
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Idle
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101947542735704306}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 0}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &1102254808008813326
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Shoot
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101104249963802978}
- {fileID: 1101806660142692138}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400006, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1102 &1102824315819425342
AnimatorState:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Moving
m_Speed: 1
m_CycleOffset: 0
m_Transitions:
- {fileID: 1101862483397811748}
m_StateMachineBehaviours: []
m_Position: {x: 50, y: 50, z: 0}
m_IKOnFeet: 0
m_WriteDefaultValues: 1
m_Mirror: 0
m_SpeedParameterActive: 0
m_MirrorParameterActive: 0
m_CycleOffsetParameterActive: 0
m_TimeParameterActive: 0
m_Motion: {fileID: 7400004, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Tag:
m_SpeedParameter:
m_MirrorParameter:
m_CycleOffsetParameter:
m_TimeParameter:
--- !u!1107 &1107772262116321704
AnimatorStateMachine:
serializedVersion: 5
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Base Layer
m_ChildStates:
- serializedVersion: 1
m_State: {fileID: 1102207974245764242}
m_Position: {x: 252, y: 48, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102824315819425342}
m_Position: {x: 252, y: 204, z: 0}
- serializedVersion: 1
m_State: {fileID: 1102254808008813326}
m_Position: {x: 420, y: 120, z: 0}
m_ChildStateMachines: []
m_AnyStateTransitions:
- {fileID: 1101366829127142966}
m_EntryTransitions: []
m_StateMachineTransitions: {}
m_StateMachineBehaviours: []
m_AnyStatePosition: {x: 60, y: 132, z: 0}
m_EntryPosition: {x: 60, y: 168, z: 0}
m_ExitPosition: {x: 60, y: 96, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
m_DefaultState: {fileID: 1102207974245764242}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a7211483bbd794b6d85ed88576e7d85c
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 9100000
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -1,12 +1,12 @@
fileFormatVersion: 2
guid: e79a606e2465b49168ad7785fd79e9d3
guid: 9b3e91ab0048a4aa3a17706a349c6bf5
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 4
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@ -21,6 +21,8 @@ TextureImporter:
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -31,14 +33,14 @@ TextureImporter:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@ -47,15 +49,17 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 8
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
@ -70,7 +74,15 @@ TextureImporter:
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@ -1,12 +1,12 @@
fileFormatVersion: 2
guid: 1df5a55dca9084efba7314d168c7106f
guid: a7467e18a834e4d1390091c8b1ea562c
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 4
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 0
enableMipMap: 1
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
@ -21,6 +21,8 @@ TextureImporter:
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -31,14 +33,14 @@ TextureImporter:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@ -47,15 +49,17 @@ TextureImporter:
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 8
textureType: 0
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
@ -70,7 +74,15 @@ TextureImporter:
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 KiB

View File

@ -1,9 +1,9 @@
fileFormatVersion: 2
guid: a623522aaab404bfb886bdd6fea0df80
guid: 2617bfecca4d44805a3a51a7aa215d7c
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 4
serializedVersion: 9
mipmaps:
mipMapMode: 0
enableMipMap: 1
@ -21,6 +21,8 @@ TextureImporter:
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
@ -31,14 +33,14 @@ TextureImporter:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -1
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
mipBias: -100
wrapU: -1
wrapV: -1
wrapW: -1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
@ -51,11 +53,13 @@ TextureImporter:
spriteTessellationDetail: -1
textureType: 1
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- buildTarget: DefaultTexturePlatform
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
@ -70,7 +74,15 @@ TextureImporter:
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,7 @@
Recon Tank (update), by Mophs
https://opengameart.org/users/mophs
Based on original work, Recon Tank, By MNDV.ecb, 2018 Eric Buisson
https://opengameart.org/content/recon-tank
CC-BY 4.0

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: c7df69c69208a455abb56f1ec2ac9906
guid: 6e745106dbbc3412bbe43eaf25dabd4f
TextScriptImporter:
externalObjects: {}
userData:

View File

@ -0,0 +1,82 @@
%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: TankMaterial
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ShaderKeywords: _EMISSION _METALLICGLOSSMAP _NORMALMAP _SPECGLOSSMAP
m_LightmapFlags: 0
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 2800000, guid: 2617bfecca4d44805a3a51a7aa215d7c, type: 3}
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: 2800000, guid: 9b3e91ab0048a4aa3a17706a349c6bf5, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: ce00d67f9368944fa8ef4de6ccc77bfa, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 2800000, guid: a7467e18a834e4d1390091c8b1ea562c, type: 3}
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}
- _SpecGlossMap:
m_Texture: {fileID: 2800000, guid: a7467e18a834e4d1390091c8b1ea562c, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1.75
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 0.09
- _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: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 1, g: 1, b: 1, a: 1}
- _SpecColor: {r: 0.2, g: 0.2, b: 0.2, a: 1}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2ef04982cb77c4fa984062fdcfc61d20
guid: 2e67e42170aa64aa9a33424f8045ac89
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000

View File

@ -0,0 +1,239 @@
fileFormatVersion: 2
guid: 38b49695fc0a4418bbc350f2366660c5
ModelImporter:
serializedVersion: 23
fileIDToRecycleName:
100000: Barrel
100002: Barrel_end
100004: Chasis
100006: Recon_Tank
100008: Recon_Tank_Rig
100010: //RootNode
100012: Root
100014: Turret
100016: Wheel_Front_L
100018: Wheel_Front_L_end
100020: Wheel_Middle_L
100022: Wheel_Middle_L_end
100024: Wheel_Rear_L
100026: Wheel_Rear_L_end
400000: Barrel
400002: Barrel_end
400004: Chasis
400006: Recon_Tank
400008: Recon_Tank_Rig
400010: //RootNode
400012: Root
400014: Turret
400016: Wheel_Front_L
400018: Wheel_Front_L_end
400020: Wheel_Middle_L
400022: Wheel_Middle_L_end
400024: Wheel_Rear_L
400026: Wheel_Rear_L_end
2100000: Recon_Tank
4300000: Recon_Tank
7400000: Recon_Tank_Rig|Drive
7400002: Recon_Tank_Rig|Forward
7400004: Recon_Tank_Rig|Idle
7400006: Recon_Tank_Rig|Shoot
9500000: //RootNode
13700000: Recon_Tank
externalObjects: {}
materials:
importMaterials: 1
materialName: 0
materialSearch: 1
materialLocation: 1
animations:
legacyGenerateAnimations: 4
bakeSimulation: 0
resampleCurves: 1
optimizeGameObjects: 0
motionNodeName:
rigImportErrors:
rigImportWarnings:
animationImportErrors:
animationImportWarnings:
animationRetargetingWarnings:
animationDoRetargetingWarnings: 0
importAnimatedCustomProperties: 0
importConstraints: 0
animationCompression: 1
animationRotationError: 0.5
animationPositionError: 0.5
animationScaleError: 0.5
animationWrapMode: 0
extraExposedTransformPaths: []
extraUserProperties: []
clipAnimations:
- serializedVersion: 16
name: Recon_Tank_Rig|Drive
takeName: Recon_Tank_Rig|Drive
firstFrame: 0
lastFrame: 1
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0
loop: 0
hasAdditiveReferencePose: 0
loopTime: 0
loopBlend: 0
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 0
keepOriginalPositionY: 1
keepOriginalPositionXZ: 0
heightFromFeet: 0
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
- serializedVersion: 16
name: Recon_Tank_Rig|Forward
takeName: Recon_Tank_Rig|Forward
firstFrame: 0
lastFrame: 25
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0
loop: 0
hasAdditiveReferencePose: 0
loopTime: 0
loopBlend: 0
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 0
keepOriginalPositionY: 1
keepOriginalPositionXZ: 0
heightFromFeet: 0
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
- serializedVersion: 16
name: Recon_Tank_Rig|Idle
takeName: Recon_Tank_Rig|Idle
firstFrame: 0
lastFrame: 11
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0
loop: 0
hasAdditiveReferencePose: 0
loopTime: 1
loopBlend: 1
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 0
keepOriginalPositionY: 1
keepOriginalPositionXZ: 0
heightFromFeet: 0
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
- serializedVersion: 16
name: Recon_Tank_Rig|Shoot
takeName: Recon_Tank_Rig|Shoot
firstFrame: 0
lastFrame: 15
wrapMode: 0
orientationOffsetY: 0
level: 0
cycleOffset: 0
loop: 0
hasAdditiveReferencePose: 0
loopTime: 0
loopBlend: 0
loopBlendOrientation: 0
loopBlendPositionY: 0
loopBlendPositionXZ: 0
keepOriginalOrientation: 0
keepOriginalPositionY: 1
keepOriginalPositionXZ: 0
heightFromFeet: 0
mirror: 0
bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
curves: []
events: []
transformMask: []
maskType: 3
maskSource: {instanceID: 0}
additiveReferencePoseFrame: 0
isReadable: 1
meshes:
lODScreenPercentages: []
globalScale: 0.15
meshCompression: 0
addColliders: 0
useSRGBMaterialColor: 1
importVisibility: 1
importBlendShapes: 1
importCameras: 1
importLights: 1
swapUVChannels: 0
generateSecondaryUV: 0
useFileUnits: 1
optimizeMeshForGPU: 1
keepQuads: 0
weldVertices: 1
preserveHierarchy: 0
indexFormat: 0
secondaryUVAngleDistortion: 8
secondaryUVAreaDistortion: 15.000001
secondaryUVHardAngle: 88
secondaryUVPackMargin: 4
useFileScale: 1
previousCalculatedGlobalScale: 0.0015
hasPreviousCalculatedGlobalScale: 1
tangentSpace:
normalSmoothAngle: 60
normalImportMode: 0
tangentImportMode: 3
normalCalculationMode: 4
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
blendShapeNormalImportMode: 1
normalSmoothingSource: 0
importAnimation: 1
copyAvatar: 0
humanDescription:
serializedVersion: 2
human: []
skeleton: []
armTwist: 0.5
foreArmTwist: 0.5
upperLegTwist: 0.5
legTwist: 0.5
armStretch: 0.05
legStretch: 0.05
feetSpacing: 0
rootMotionBoneName:
hasTranslationDoF: 0
hasExtraRoot: 0
skeletonHasParents: 1
lastHumanDescriptionAvatarSource: {instanceID: 0}
animationType: 2
humanoidOversampling: 1
additionalBone: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,246 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &63476987332307980
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8035186136109819211}
- component: {fileID: 9118274893554935717}
- component: {fileID: 69063397099238371}
m_Layer: 0
m_Name: 3D Model
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8035186136109819211
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 63476987332307980}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.05, y: 0.1, z: 0.05}
m_Children: []
m_Father: {fileID: 24373266488650541}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!33 &9118274893554935717
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 63476987332307980}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &69063397099238371
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 63476987332307980}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: cba1b63a0bccc4b12ac25f05d0ae2dd1, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
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!1 &5890560936853567077
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 24373266488650541}
- component: {fileID: 1713098107664522388}
- component: {fileID: 2355290524794870353}
- component: {fileID: 4629190479245867726}
- component: {fileID: 7082621516996595528}
m_Layer: 0
m_Name: Projectile
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &24373266488650541
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
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: 8035186136109819211}
- {fileID: 7830988697844474908}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1713098107664522388
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ServerOnly: 0
m_LocalPlayerAuthority: 0
m_AssetId: b7dd46dbf38c643f09e206f9fa4be008
m_SceneId: 0
--- !u!136 &2355290524794870353
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
m_Radius: 0.05
m_Height: 0.2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &4629190479245867726
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 1
m_Constraints: 0
m_CollisionDetection: 1
--- !u!114 &7082621516996595528
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5890560936853567077}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 8f49b83f111a64bc7a5275af4f6f930b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
destroyAfter: 5
rigidBody: {fileID: 4629190479245867726}
force: 1000
--- !u!1 &9126921595194253319
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7830988697844474908}
- component: {fileID: 4878977110396366525}
m_Layer: 0
m_Name: Point Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7830988697844474908
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9126921595194253319}
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: 24373266488650541}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!108 &4878977110396366525
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9126921595194253319}
m_Enabled: 1
serializedVersion: 8
m_Type: 2
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Intensity: 5
m_Range: 2
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
m_Bias: 0.05
m_NormalBias: 0.4
m_NearPlane: 0.2
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 3
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b7dd46dbf38c643f09e206f9fa4be008
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,312 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1916082411674582
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4492442352427800}
- component: {fileID: 114118589361100106}
- component: {fileID: 2240606817507776182}
- component: {fileID: 114250499875391520}
- component: {fileID: 6900008319038825817}
- component: {fileID: 5194388907919410155}
- component: {fileID: 114654712548978148}
m_Layer: 0
m_Name: Tank
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4492442352427800
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
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: 7831918942946891954}
- {fileID: 6564220120147636086}
- {fileID: 5718089106632469514}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114118589361100106
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9b91ecbcc199f4492b9a91e820070131, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ServerOnly: 0
m_LocalPlayerAuthority: 1
m_AssetId: 6f43bf5488a7443d19ab2a83c6b91f35
m_SceneId: 0
--- !u!95 &2240606817507776182
Animator:
serializedVersion: 3
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_Avatar: {fileID: 9000000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_Controller: {fileID: 9100000, guid: a7211483bbd794b6d85ed88576e7d85c, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!114 &114250499875391520
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2f74aedd71d9a4f55b3ce499326d45fb, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
compressRotation: 1
--- !u!195 &6900008319038825817
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 1
m_Acceleration: 1
avoidancePriority: 50
m_AngularSpeed: 120
m_StoppingDistance: 0
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 0.5
m_BaseOffset: 0
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 0
--- !u!135 &5194388907919410155
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0.25, z: 0}
--- !u!114 &114654712548978148
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1916082411674582}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7deadf756194d461e9140e42d651693b, type: 3}
m_Name:
m_EditorClassIdentifier:
syncInterval: 0.1
agent: {fileID: 6900008319038825817}
animator: {fileID: 2240606817507776182}
rotationSpeed: 80
shootKey: 32
projectilePrefab: {fileID: 5890560936853567077, guid: b7dd46dbf38c643f09e206f9fa4be008,
type: 3}
projectileMount: {fileID: 5718089106632469514}
--- !u!1 &4426914200102054949
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6564220120147636086}
- component: {fileID: 7604806193092689376}
m_Layer: 0
m_Name: Spot Light
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6564220120147636086
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4426914200102054949}
m_LocalRotation: {x: 0.02281505, y: -0, z: -0, w: 0.9997397}
m_LocalPosition: {x: 0.07, y: 0.46, z: 0.126}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4492442352427800}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 2.615, y: 0, z: 0}
--- !u!108 &7604806193092689376
Light:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4426914200102054949}
m_Enabled: 1
serializedVersion: 8
m_Type: 0
m_Color: {r: 1, g: 0.9205329, b: 0.7877358, a: 1}
m_Intensity: 3
m_Range: 15
m_SpotAngle: 80
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_Cookie: {fileID: 0}
m_DrawHalo: 0
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_Lightmapping: 4
m_LightShadowCasterMode: 0
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &4730779867780281009
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5718089106632469514}
m_Layer: 0
m_Name: ProjectileMount
m_TagString: Untagged
m_Icon: {fileID: -964228994112308473, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5718089106632469514
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4730779867780281009}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.412, z: 0.936}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4492442352427800}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &7831918942947279416
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 4492442352427800}
m_Modifications:
- target: {fileID: 100010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_Name
value: 3D Model
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 13700000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
propertyPath: m_Materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 2e67e42170aa64aa9a33424f8045ac89, type: 2}
m_RemovedComponents:
- {fileID: 9500000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
m_SourcePrefab: {fileID: 100100000, guid: 38b49695fc0a4418bbc350f2366660c5, type: 3}
--- !u!4 &7831918942946891954 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 400010, guid: 38b49695fc0a4418bbc350f2366660c5,
type: 3}
m_PrefabInstance: {fileID: 7831918942947279416}
m_PrefabAsset: {fileID: 0}

Some files were not shown because too many files have changed in this diff Show More