SynchronizeVelocity
How do I use Synchronize Velocity
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: PhotonRigidbody2DViewEditor.cs
Copy
7 public override void OnInspectorGUI()
8 {
9 PhotonGUI.ContainerHeader("Options");
10
11 Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight*2 + 10);
12
13 Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight);
14 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity"));
15
16 propertyRect.y += EditorGUIUtility.singleLineHeight;
17 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity"));
18 }
File name: PhotonRigidbodyViewEditor.cs
Copy
7 public override void OnInspectorGUI()
8 {
9 PhotonGUI.ContainerHeader("Options");
10
11 Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight*2 + 10);
12
13 Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight);
14 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity"));
15
16 propertyRect.y += EditorGUIUtility.singleLineHeight;
17 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity"));
18 }
File name: PhotonRigidbody2DView.cs
Copy
32 void OnPhotonSerializeView( PhotonStream stream, PhotonMessageInfo info )
33 {
34 if( stream.isWriting == true )
35 {
36 if( m_SynchronizeVelocity == true )
37 {
38 stream.SendNext( m_Body.velocity );
39 }
40
41 if( m_SynchronizeAngularVelocity == true )
42 {
43 stream.SendNext( m_Body.angularVelocity );
44 }
45 }
46 else
47 {
48 if( m_SynchronizeVelocity == true )
49 {
50 m_Body.velocity = (Vector2)stream.ReceiveNext();
51 }
52
53 if( m_SynchronizeAngularVelocity == true )
54 {
55 m_Body.angularVelocity = (float)stream.ReceiveNext();
56 }
57 }
58 }
File name: PhotonRigidbodyView.cs
Copy
32 void OnPhotonSerializeView( PhotonStream stream, PhotonMessageInfo info )
33 {
34 if( stream.isWriting == true )
35 {
36 if( m_SynchronizeVelocity == true )
37 {
38 stream.SendNext( m_Body.velocity );
39 }
40
41 if( m_SynchronizeAngularVelocity == true )
42 {
43 stream.SendNext( m_Body.angularVelocity );
44 }
45 }
46 else
47 {
48 if( m_SynchronizeVelocity == true )
49 {
50 m_Body.velocity = (Vector3)stream.ReceiveNext();
51 }
52
53 if( m_SynchronizeAngularVelocity == true )
54 {
55 m_Body.angularVelocity = (Vector3)stream.ReceiveNext();
56 }
57 }
58 }
SynchronizeVelocity 120 lượt xem
Gõ tìm kiếm nhanh...