RotationModel









How do I use Rotation Model
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: PhotonTransformViewEditor.cs Copy
84     private void SetupSerializedProperties()
85     {
86         this.m_SynchronizePositionProperty = serializedObject.FindProperty("m_PositionModel.SynchronizeEnabled");
87         this.m_SynchronizeRotationProperty = serializedObject.FindProperty("m_RotationModel.SynchronizeEnabled");
88         this.m_SynchronizeScaleProperty = serializedObject.FindProperty("m_ScaleModel.SynchronizeEnabled");
89     }
File name: PhotonTransformViewEditor.cs Copy
309     private void DrawSynchronizeRotationData()
310     {
311         if (this.m_SynchronizeRotationProperty == null || this.m_SynchronizeRotationProperty.boolValue == false)
312         {
313             return;
314         }
315
316         SerializedProperty interpolateRotationProperty = serializedObject.FindProperty("m_RotationModel.InterpolateOption");
317         PhotonTransformViewRotationModel.InterpolateOptions interpolateOption =
318             (PhotonTransformViewRotationModel.InterpolateOptions) interpolateRotationProperty.enumValueIndex;
319
320         float containerHeight = 20;
321
322         switch (interpolateOption)
323         {
324             case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
325             case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
326                 containerHeight += EDITOR_LINE_HEIGHT;
327                 break;
328         }
329
330         if (this.m_InterpolateRotationHelpOpen == true)
331         {
332             containerHeight += GetInterpolateHelpBoxHeight();
333         }
334
335         Rect rect = PhotonGUI.ContainerBody(containerHeight);
336         Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
337
338         DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateRotationHelpOpen, interpolateRotationProperty, INTERPOLATE_TOOLTIP);
339         DrawHelpBox(ref propertyRect, this.m_InterpolateRotationHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
340
341         switch (interpolateOption)
342         {
343             case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
344                 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_RotationModel.InterpolateRotateTowardsSpeed"),
345                     new GUIContent("RotateTowards Speed"));
346                 break;
347             case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
348                 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_RotationModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
349                 break;
350         }
351     }
File name: PhotonTransformView.cs Copy
38     void Awake()
39     {
40         m_PhotonView = GetComponent();
41
42         m_PositionControl = new PhotonTransformViewPositionControl( m_PositionModel );
43         m_RotationControl = new PhotonTransformViewRotationControl( m_RotationModel );
44         m_ScaleControl = new PhotonTransformViewScaleControl( m_ScaleModel );
45     }
File name: PhotonTransformView.cs Copy
69     void UpdateRotation()
70     {
71         if( m_RotationModel.SynchronizeEnabled == false || m_ReceivedNetworkUpdate == false )
72         {
73             return;
74         }
75
76         transform.localRotation = m_RotationControl.GetRotation( transform.localRotation );
77     }
File name: PhotonTransformViewRotationControl.cs Copy
9     public PhotonTransformViewRotationControl( PhotonTransformViewRotationModel model )
10     {
11         m_Model = model;
12     }
File name: PhotonTransformViewRotationControl.cs Copy
14     public Quaternion GetRotation( Quaternion currentRotation )
15     {
16         switch( m_Model.InterpolateOption )
17         {
18         default:
19         case PhotonTransformViewRotationModel.InterpolateOptions.Disabled:
20             return m_NetworkRotation;
21         case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
22             return Quaternion.RotateTowards( currentRotation, m_NetworkRotation, m_Model.InterpolateRotateTowardsSpeed * Time.deltaTime );
23         case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
24             return Quaternion.Lerp( currentRotation, m_NetworkRotation, m_Model.InterpolateLerpSpeed * Time.deltaTime );
25         }
26     }

Download file with original file name:RotationModel

RotationModel 118 lượt xem

Gõ tìm kiếm nhanh...