PositionModel
How do I use Position 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
96 private void DrawSynchronizePositionData()
97 {
98 if (this.m_SynchronizePositionProperty == null || this.m_SynchronizePositionProperty.boolValue == false)
99 {
100 return;
101 }
102
103 SerializedProperty interpolatePositionProperty = serializedObject.FindProperty("m_PositionModel.InterpolateOption");
104 PhotonTransformViewPositionModel.InterpolateOptions interpolateOption = (PhotonTransformViewPositionModel.InterpolateOptions)interpolatePositionProperty.enumValueIndex;
105
106 SerializedProperty extrapolatePositionProperty = serializedObject.FindProperty("m_PositionModel.ExtrapolateOption");
107 PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption = (PhotonTransformViewPositionModel.ExtrapolateOptions)extrapolatePositionProperty.enumValueIndex;
108
109 float containerHeight = 155;
110
111 switch (interpolateOption)
112 {
113 case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
114 case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
115 containerHeight += EDITOR_LINE_HEIGHT;
116 break;
117 /*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
118 containerHeight += EDITOR_LINE_HEIGHT*3;
119 break;*/
120 }
121
122 if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
123 {
124 containerHeight += EDITOR_LINE_HEIGHT;
125 }
126
127 switch (extrapolateOption)
128 {
129 case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
130 containerHeight += EDITOR_LINE_HEIGHT;
131 break;
132 }
133
134 if (this.m_InterpolateHelpOpen == true)
135 {
136 containerHeight += GetInterpolateHelpBoxHeight();
137 }
138
139 if (this.m_ExtrapolateHelpOpen == true)
140 {
141 containerHeight += GetExtrapolateHelpBoxHeight();
142 }
143
144 // removed Gizmo Options. -3 lines, -1 splitter
145 containerHeight -= EDITOR_LINE_HEIGHT * 2;
146
147 Rect rect = PhotonGUI.ContainerBody(containerHeight);
148
149 Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
150
151 DrawTeleport(ref propertyRect);
152 DrawSplitter(ref propertyRect);
153
154 DrawSynchronizePositionDataInterpolation(ref propertyRect, interpolatePositionProperty, interpolateOption);
155 DrawSplitter(ref propertyRect);
156
157 DrawSynchronizePositionDataExtrapolation(ref propertyRect, extrapolatePositionProperty, extrapolateOption);
158 DrawSplitter(ref propertyRect);
159
160 DrawSynchronizePositionDataGizmos(ref propertyRect);
161 }
File name: PhotonTransformViewEditor.cs
Copy
181 private void DrawSynchronizePositionDataGizmos(ref Rect propertyRect)
182 {
183 GUI.enabled = true;
184 /*PhotonGUI.DrawGizmoOptions(propertyRect, "Synchronized Position Gizmo",
185 serializedObject.FindProperty("m_PositionModel.DrawNetworkGizmo"),
186 serializedObject.FindProperty("m_PositionModel.NetworkGizmoColor"),
187 serializedObject.FindProperty("m_PositionModel.NetworkGizmoType"),
188 serializedObject.FindProperty("m_PositionModel.NetworkGizmoSize"));
189 propertyRect.y += EDITOR_LINE_HEIGHT;
190
191 PhotonGUI.DrawGizmoOptions(propertyRect, "Extrapolated Position Gizmo",
192 serializedObject.FindProperty("m_PositionModel.DrawExtrapolatedGizmo"),
193 serializedObject.FindProperty("m_PositionModel.ExtrapolatedGizmoColor"),
194 serializedObject.FindProperty("m_PositionModel.ExtrapolatedGizmoType"),
195 serializedObject.FindProperty("m_PositionModel.ExtrapolatedGizmoSize"));
196 propertyRect.y += EDITOR_LINE_HEIGHT;*/
197
198 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.DrawErrorGizmo"),
199 new GUIContent("Draw synchronized position error"));
200 propertyRect.y += EDITOR_LINE_HEIGHT;
201 }
File name: PhotonTransformViewEditor.cs
Copy
232 private void DrawSynchronizePositionDataExtrapolation(ref Rect propertyRect, SerializedProperty extrapolatePositionProperty, PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption)
233 {
234 DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_ExtrapolateHelpOpen, extrapolatePositionProperty, EXTRAPOLATE_TOOLTIP);
235 DrawHelpBox(ref propertyRect, this.m_ExtrapolateHelpOpen, GetExtrapolateHelpBoxHeight(), EXTRAPOLATE_HELP, EXTRAPOLATE_HELP_URL);
236
237 if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
238 {
239 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.ExtrapolateIncludingRoundTripTime"));
240 propertyRect.y += EDITOR_LINE_HEIGHT;
241 }
242
243 switch (extrapolateOption)
244 {
245 case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
246 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.ExtrapolateSpeed"));
247 propertyRect.y += EDITOR_LINE_HEIGHT;
248 break;
249 }
250 }
File name: PhotonTransformViewEditor.cs
Copy
252 private void DrawTeleport(ref Rect propertyRect)
253 {
254 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.TeleportEnabled"),
255 new GUIContent("Enable teleport for great distances"));
256 propertyRect.y += EDITOR_LINE_HEIGHT;
257
258 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.TeleportIfDistanceGreaterThan"),
259 new GUIContent("Teleport if distance greater than"));
260 propertyRect.y += EDITOR_LINE_HEIGHT;
261 }
File name: PhotonTransformViewEditor.cs
Copy
264 PhotonTransformViewPositionModel.InterpolateOptions interpolateOption)
265 {
266 DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateHelpOpen, interpolatePositionProperty, INTERPOLATE_TOOLTIP);
267 DrawHelpBox(ref propertyRect, this.m_InterpolateHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
268
269 switch (interpolateOption)
270 {
271 case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
272 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsSpeed"),
273 new GUIContent("MoveTowards Speed"));
274 propertyRect.y += EDITOR_LINE_HEIGHT;
275 break;
276
277 case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
278 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
279 propertyRect.y += EDITOR_LINE_HEIGHT;
280 break;
281
282 /*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
283 Rect curveRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width - 100, propertyRect.height);
284 EditorGUI.PropertyField(curveRect, serializedObject.FindProperty("m_PositionModel.InterpolateSpeedCurve"), new GUIContent("MoveTowards Speed Curve"));
285
286 Rect labelRect = new Rect(propertyRect.xMax - 95, propertyRect.yMin, 10, propertyRect.height);
287 GUI.Label(labelRect, "x");
288
289 Rect multiplierRect = new Rect(propertyRect.xMax - 80, propertyRect.yMin, 80, propertyRect.height);
290 EditorGUI.PropertyField(multiplierRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsSpeed"), GUIContent.none);
291 propertyRect.y += EDITOR_LINE_HEIGHT;
292
293 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsAcceleration"),
294 new GUIContent("Acceleration"));
295 propertyRect.y += EDITOR_LINE_HEIGHT;
296
297 EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsDeceleration"),
298 new GUIContent("Deceleration"));
299 propertyRect.y += EDITOR_LINE_HEIGHT;
300 break;*/
301 }
302 }
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
59 void UpdatePosition()
60 {
61 if( m_PositionModel.SynchronizeEnabled == false || m_ReceivedNetworkUpdate == false )
62 {
63 return;
64 }
65
66 transform.localPosition = m_PositionControl.UpdatePosition( transform.localPosition );
67 }
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: PhotonTransformViewPositionControl.cs
Copy
18 public PhotonTransformViewPositionControl( PhotonTransformViewPositionModel model )
19 {
20 m_Model = model;
21 }
Download file with original file name:PositionModel
PositionModel 133 lượt xem
Gõ tìm kiếm nhanh...