Scale









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

Featured Snippets


File name: JumpAndRunMovement.cs Copy
40     void UpdateFacingDirection()
41     {
42         if( m_Body.velocity.x > 0.2f )
43         {
44             transform.localScale = new Vector3( 1, 1, 1 );
45         }
46         else if( m_Body.velocity.x < -0.2f )
47         {
48             transform.localScale = new Vector3( -1, 1, 1 );
49         }
50     }
File name: PhotonTransformViewEditor.cs Copy
47     public override void OnInspectorGUI()
48     {
49         this.m_Target = (PhotonTransformView) target;
50
51         DrawIsPlayingWarning();
52         GUI.enabled = !Application.isPlaying;
53
54         DrawSynchronizePositionHeader();
55         DrawSynchronizePositionData();
56
57         GUI.enabled = !Application.isPlaying;
58         DrawSynchronizeRotationHeader();
59         DrawSynchronizeRotationData();
60
61         GUI.enabled = !Application.isPlaying;
62         DrawSynchronizeScaleHeader();
63         DrawSynchronizeScaleData();
64
65         serializedObject.ApplyModifiedProperties();
66
67         GUI.enabled = true;
68     }
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
353     private void DrawSynchronizeScaleHeader()
354     {
355         DrawHeader("Synchronize Scale", this.m_SynchronizeScaleProperty);
356     }
File name: PhotonTransformViewEditor.cs Copy
358     private void DrawSynchronizeScaleData()
359     {
360         if (this.m_SynchronizeScaleProperty == null || this.m_SynchronizeScaleProperty.boolValue == false)
361         {
362             return;
363         }
364
365         SerializedProperty interpolateScaleProperty = serializedObject.FindProperty("m_ScaleModel.InterpolateOption");
366         PhotonTransformViewScaleModel.InterpolateOptions interpolateOption = (PhotonTransformViewScaleModel.InterpolateOptions) interpolateScaleProperty.enumValueIndex;
367
368         float containerHeight = EDITOR_LINE_HEIGHT;
369
370         switch (interpolateOption)
371         {
372             case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
373             case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
374                 containerHeight += EDITOR_LINE_HEIGHT;
375                 break;
376         }
377
378         if (this.m_InterpolateScaleHelpOpen == true)
379         {
380             containerHeight += GetInterpolateHelpBoxHeight();
381         }
382
383         Rect rect = PhotonGUI.ContainerBody(containerHeight);
384         Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
385
386         DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateScaleHelpOpen, interpolateScaleProperty, INTERPOLATE_TOOLTIP);
387         DrawHelpBox(ref propertyRect, this.m_InterpolateScaleHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
388
389         switch (interpolateOption)
390         {
391             case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
392                 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateMoveTowardsSpeed"),
393                     new GUIContent("MoveTowards Speed"));
394                 break;
395             case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
396                 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
397                 break;
398         }
399     }
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
47     void Update()
48     {
49         if( m_PhotonView == null || m_PhotonView.isMine == true || PhotonNetwork.connected == false )
50         {
51             return;
52         }
53
54         UpdatePosition();
55         UpdateRotation();
56         UpdateScale();
57     }
File name: PhotonTransformView.cs Copy
79     void UpdateScale()
80     {
81         if( m_ScaleModel.SynchronizeEnabled == false || m_ReceivedNetworkUpdate == false )
82         {
83             return;
84         }
85
86         transform.localScale = m_ScaleControl.GetScale( transform.localScale );
87     }
File name: PhotonTransformView.cs Copy
102     void OnPhotonSerializeView( PhotonStream stream, PhotonMessageInfo info )
103     {
104         m_PositionControl.OnPhotonSerializeView( transform.localPosition, stream, info );
105         m_RotationControl.OnPhotonSerializeView( transform.localRotation, stream, info );
106         m_ScaleControl.OnPhotonSerializeView( transform.localScale, stream, info );
107
108         if( m_PhotonView.isMine == false && m_PositionModel.DrawErrorGizmo == true )
109         {
110             DoDrawEstimatedPositionError();
111         }
112
113         if( stream.isReading == true )
114         {
115             m_ReceivedNetworkUpdate = true;
116         }
117     }
File name: PhotonTransformViewScaleControl.cs Copy
9     public PhotonTransformViewScaleControl( PhotonTransformViewScaleModel model )
10     {
11         m_Model = model;
12     }

Download file with original file name:Scale

Scale 112 lượt xem

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