public void Init() { if (this.m_Initialized) return; this.m_Initialized = true; this.sync = this.target as NetworkTransformChild; this.m_Target = this.serializedObject.FindProperty("m_Target"); if ((Object) this.sync.GetComponent<NetworkTransform>() == (Object) null) { if (LogFilter.logError) Debug.LogError((object) "NetworkTransformChild must be on the root object with the NetworkTransform, not on the child node"); this.m_Target.objectReferenceValue = (Object) null; } this.m_MovementThreshold = this.serializedObject.FindProperty("m_MovementThreshold"); this.m_InterpolateRotation = this.serializedObject.FindProperty("m_InterpolateRotation"); this.m_InterpolateMovement = this.serializedObject.FindProperty("m_InterpolateMovement"); this.m_RotationSyncCompression = this.serializedObject.FindProperty("m_RotationSyncCompression"); this.m_NetworkSendIntervalProperty = this.serializedObject.FindProperty("m_SendInterval"); this.m_NetworkSendIntervalLabel = new GUIContent("Network Send Rate (seconds)", "Number of network updates per second"); ++EditorGUI.indentLevel; this.m_MovementThresholdLabel = new GUIContent("Movement Threshold"); this.m_InterpolateRotationLabel = new GUIContent("Interpolate Rotation Factor"); this.m_InterpolateMovementLabel = new GUIContent("Interpolate Movement Factor"); this.m_RotationSyncCompressionLabel = new GUIContent("Compress Rotation"); --EditorGUI.indentLevel; }
/* [Command] public void Cmd_InteractableMove(string name, float amount) { GameObject mirror = GameObject.Find(name);aaaaaaaaab float rotateSpeed = 10; Debug.Log("Rotating : " + name + " by : " + amount); float maxNegativeRotation = mirror.GetComponent<VRStandardAssets.Examples.spt_mirrorHandle>().maxNegativeRotation; float maxPositiveRotation = mirror.GetComponent<VRStandardAssets.Examples.spt_mirrorHandle>().maxPositiveRotation; Vector3 initialRotation = mirror.transform.rotation.eulerAngles; Vector3 newRotation = mirror.transform.rotation.eulerAngles; mirror.transform.root.GetComponent<NetworkTransformChild>().enabled = false; Debug.Log("Initial : " + mirror.transform.rotation.eulerAngles); mirror.transform.Rotate(Vector3.up * -amount * Time.deltaTime * rotateSpeed); Debug.Log("After : " + mirror.transform.rotation.eulerAngles); //reactiveNetworkTransform( mirror.transform.root.GetComponent<NetworkTransformChild>() ); //get room and mark dirty bits, oh my. //mirror.transform.root.gameObject.GetComponent<NetworkTransformChild>().SetDirtyBit(); } */ private IEnumerable reactiveNetworkTransform( NetworkTransformChild obj ) { yield return new WaitForSeconds(5); obj.enabled = true; }
protected override void Start() { base.Start(); NetworkTransformChild[] networkTransforms = GetComponents<NetworkTransformChild>(); foreach (NetworkTransformChild child in networkTransforms) { if (child.target.gameObject.name == "Temp_Transform" || child.target.gameObject.name.Contains("Pickup")) { networkedTransform = child; break; } } HasMirror(); //networkedTransform = GetComponent<NetworkTransformChild>(); }
static internal void HandleChildTransform(NetworkMessage netMsg) { NetworkInstanceId netId = netMsg.reader.ReadNetworkId(); uint childIndex = netMsg.reader.ReadPackedUInt32(); #if UNITY_EDITOR Profiler.IncrementStatIncoming(MsgType.LocalChildTransform, "16:LocalChildTransform"); #endif GameObject foundObj = NetworkServer.FindLocalObject(netId); if (foundObj == null) { if (LogFilter.logError) { Debug.LogError("Received NetworkTransformChild data for GameObject that doesn't exist"); } return; } var children = foundObj.GetComponents <NetworkTransformChild>(); if (children == null || children.Length == 0) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no children"); } return; } if (childIndex >= children.Length) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform childIndex invalid"); } return; } NetworkTransformChild foundSync = children[childIndex]; if (foundSync == null) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform null target"); } return; } if (!foundSync.localPlayerAuthority) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no localPlayerAuthority"); } return; } if (!netMsg.conn.clientOwnedObjects.Contains(netId)) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkTransformChild netId:" + netId + " is not for a valid player"); } return; } foundSync.UnserializeModeTransform(netMsg.reader, false); foundSync.m_LastClientSyncTime = Time.time; if (!foundSync.isClient) { // dedicated server wont interpolate, so snap. foundSync.m_Target.localPosition = foundSync.m_TargetSyncPosition; foundSync.m_Target.localRotation = foundSync.m_TargetSyncRotation3D; } }
internal static void HandleChildTransform(NetworkMessage netMsg) { NetworkInstanceId networkInstanceId = netMsg.reader.ReadNetworkId(); uint num = netMsg.reader.ReadPackedUInt32(); GameObject gameObject = NetworkServer.FindLocalObject(networkInstanceId); if (gameObject == null) { if (LogFilter.logError) { Debug.LogError("Received NetworkTransformChild data for GameObject that doesn't exist"); } } else { NetworkTransformChild[] components = gameObject.GetComponents <NetworkTransformChild>(); if (components == null || components.Length == 0) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no children"); } } else if ((ulong)num >= (ulong)((long)components.Length)) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform childIndex invalid"); } } else { NetworkTransformChild networkTransformChild = components[(int)((UIntPtr)num)]; if (networkTransformChild == null) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform null target"); } } else if (!networkTransformChild.localPlayerAuthority) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no localPlayerAuthority"); } } else if (!netMsg.conn.clientOwnedObjects.Contains(networkInstanceId)) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkTransformChild netId:" + networkInstanceId + " is not for a valid player"); } } else { networkTransformChild.UnserializeModeTransform(netMsg.reader, false); networkTransformChild.m_LastClientSyncTime = Time.time; if (!networkTransformChild.isClient) { networkTransformChild.m_Target.localPosition = networkTransformChild.m_TargetSyncPosition; networkTransformChild.m_Target.localRotation = networkTransformChild.m_TargetSyncRotation3D; } } } } }
internal static void HandleChildTransform(NetworkMessage netMsg) { NetworkInstanceId netId = netMsg.reader.ReadNetworkId(); uint index = netMsg.reader.ReadPackedUInt32(); NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, 0x10, "16:LocalChildTransform", 1); GameObject obj2 = NetworkServer.FindLocalObject(netId); if (obj2 == null) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no gameObject"); } } else { NetworkTransformChild[] components = obj2.GetComponents <NetworkTransformChild>(); if ((components == null) || (components.Length == 0)) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no children"); } } else if (index >= components.Length) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform childIndex invalid"); } } else { NetworkTransformChild child = components[index]; if (child == null) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform null target"); } } else if (!child.localPlayerAuthority) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no localPlayerAuthority"); } } else if (!netMsg.conn.clientOwnedObjects.Contains(netId)) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkTransformChild netId:" + netId + " is not for a valid player"); } } else { child.UnserializeModeTransform(netMsg.reader, false); child.m_LastClientSyncTime = Time.time; if (!child.isClient) { child.m_Target.localPosition = child.m_TargetSyncPosition; child.m_Target.localRotation = child.m_TargetSyncRotation3D; } } } } }
internal static void HandleChildTransform(NetworkMessage netMsg) { NetworkInstanceId netId = netMsg.reader.ReadNetworkId(); uint num = netMsg.reader.ReadPackedUInt32(); NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, (short)16, "16:LocalChildTransform", 1); GameObject localObject = NetworkServer.FindLocalObject(netId); if ((UnityEngine.Object)localObject == (UnityEngine.Object)null) { if (!LogFilter.logError) { return; } Debug.LogError((object)"HandleChildTransform no gameObject"); } else { NetworkTransformChild[] components = localObject.GetComponents <NetworkTransformChild>(); if (components == null || components.Length == 0) { if (!LogFilter.logError) { return; } Debug.LogError((object)"HandleChildTransform no children"); } else if ((long)num >= (long)components.Length) { if (!LogFilter.logError) { return; } Debug.LogError((object)"HandleChildTransform childIndex invalid"); } else { NetworkTransformChild networkTransformChild = components[(IntPtr)num]; if ((UnityEngine.Object)networkTransformChild == (UnityEngine.Object)null) { if (!LogFilter.logError) { return; } Debug.LogError((object)"HandleChildTransform null target"); } else if (!networkTransformChild.localPlayerAuthority) { if (!LogFilter.logError) { return; } Debug.LogError((object)"HandleChildTransform no localPlayerAuthority"); } else if (!netMsg.conn.clientOwnedObjects.Contains(netId)) { if (!LogFilter.logWarn) { return; } Debug.LogWarning((object)("NetworkTransformChild netId:" + (object)netId + " is not for a valid player")); } else { networkTransformChild.UnserializeModeTransform(netMsg.reader, false); networkTransformChild.m_LastClientSyncTime = Time.time; if (networkTransformChild.isClient) { return; } networkTransformChild.m_Target.localPosition = networkTransformChild.m_TargetSyncPosition; networkTransformChild.m_Target.localRotation = networkTransformChild.m_TargetSyncRotation3D; } } } }
static internal void HandleChildTransform(NetworkMessage netMsg) { LocalChildTransformMessage message = netMsg.ReadMessage <LocalChildTransformMessage>(); #if UNITY_EDITOR UnityEditor.NetworkDetailStats.IncrementStat( UnityEditor.NetworkDetailStats.NetworkDirection.Incoming, (short)MsgType.LocalChildTransform, "16:LocalChildTransform", 1); #endif GameObject foundObj = NetworkServer.FindLocalObject(message.netId); if (foundObj == null) { if (LogFilter.logError) { Debug.LogError("Received NetworkTransformChild data for GameObject that doesn't exist"); } return; } var children = foundObj.GetComponents <NetworkTransformChild>(); if (children == null || children.Length == 0) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no children"); } return; } if (message.childIndex >= children.Length) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform childIndex invalid"); } return; } NetworkTransformChild foundSync = children[message.childIndex]; if (foundSync == null) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform null target"); } return; } if (!foundSync.localPlayerAuthority) { if (LogFilter.logError) { Debug.LogError("HandleChildTransform no localPlayerAuthority"); } return; } if (!netMsg.conn.clientOwnedObjects.Contains(message.netId)) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkTransformChild netId:" + message.netId + " is not for a valid player"); } return; } foundSync.UnserializeModeTransform(new NetworkReader(message.payload), false); foundSync.m_LastClientSyncTime = Time.time; if (!foundSync.isClient) { // dedicated server wont interpolate, so snap. foundSync.m_Target.localPosition = foundSync.m_TargetSyncPosition; foundSync.m_Target.localRotation = foundSync.m_TargetSyncRotation3D; } }