first commit
This commit is contained in:
@ -0,0 +1,40 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// <copyright file="PhotonAnimatorViewEditor.cs" company="Exit Games GmbH">
|
||||
// PhotonNetwork Framework for Unity - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This is a custom editor for the AnimatorView component.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
namespace Photon.Pun
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor(typeof(MonoBehaviourPun))]
|
||||
public abstract class MonoBehaviourPunEditor : Editor
|
||||
{
|
||||
MonoBehaviourPun mbTarget;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mbTarget = target as MonoBehaviourPun;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
mbTarget = target as MonoBehaviourPun;
|
||||
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (mbTarget.photonView == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Unable to find a PhotonView on this GameObject or on any parent GameObject.", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6da457ee57ad5794782f1f76644536e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,295 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// <copyright file="PhotonAnimatorViewEditor.cs" company="Exit Games GmbH">
|
||||
// PhotonNetwork Framework for Unity - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This is a custom editor for the AnimatorView component.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Photon.Pun
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.Animations;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CustomEditor(typeof(PhotonAnimatorView))]
|
||||
public class PhotonAnimatorViewEditor : MonoBehaviourPunEditor
|
||||
{
|
||||
private Animator m_Animator;
|
||||
private PhotonAnimatorView m_Target;
|
||||
private AnimatorController m_Controller;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (this.m_Animator == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox("GameObject doesn't have an Animator component to synchronize", MessageType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
this.DrawWeightInspector();
|
||||
|
||||
if (this.GetLayerCount() == 0)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Animator doesn't have any layers setup to synchronize", MessageType.Warning);
|
||||
}
|
||||
|
||||
this.DrawParameterInspector();
|
||||
|
||||
if (this.GetParameterCount() == 0)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Animator doesn't have any parameters setup to synchronize", MessageType.Warning);
|
||||
}
|
||||
|
||||
this.serializedObject.ApplyModifiedProperties();
|
||||
|
||||
//GUILayout.Label( "m_SynchronizeLayers " + serializedObject.FindProperty( "m_SynchronizeLayers" ).arraySize );
|
||||
//GUILayout.Label( "m_SynchronizeParameters " + serializedObject.FindProperty( "m_SynchronizeParameters" ).arraySize );
|
||||
}
|
||||
|
||||
|
||||
private int GetLayerCount()
|
||||
{
|
||||
return (this.m_Controller == null) ? 0 : this.m_Controller.layers.Length;
|
||||
}
|
||||
|
||||
private int GetParameterCount()
|
||||
{
|
||||
return (this.m_Controller == null) ? 0 : this.m_Controller.parameters.Length;
|
||||
}
|
||||
|
||||
private AnimatorControllerParameter GetAnimatorControllerParameter(int i)
|
||||
{
|
||||
return this.m_Controller.parameters[i];
|
||||
}
|
||||
|
||||
|
||||
private RuntimeAnimatorController GetEffectiveController(Animator animator)
|
||||
{
|
||||
RuntimeAnimatorController controller = animator.runtimeAnimatorController;
|
||||
|
||||
AnimatorOverrideController overrideController = controller as AnimatorOverrideController;
|
||||
while (overrideController != null)
|
||||
{
|
||||
controller = overrideController.runtimeAnimatorController;
|
||||
overrideController = controller as AnimatorOverrideController;
|
||||
}
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
this.m_Target = (PhotonAnimatorView)this.target;
|
||||
this.m_Animator = this.m_Target.GetComponent<Animator>();
|
||||
|
||||
if (m_Animator)
|
||||
{
|
||||
this.m_Controller = this.GetEffectiveController(this.m_Animator) as AnimatorController;
|
||||
|
||||
this.CheckIfStoredParametersExist();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawWeightInspector()
|
||||
{
|
||||
SerializedProperty foldoutProperty = this.serializedObject.FindProperty("ShowLayerWeightsInspector");
|
||||
foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Layer Weights", foldoutProperty.boolValue);
|
||||
|
||||
if (foldoutProperty.boolValue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float lineHeight = 20;
|
||||
Rect containerRect = PhotonGUI.ContainerBody(this.GetLayerCount() * lineHeight);
|
||||
|
||||
for (int i = 0; i < this.GetLayerCount(); ++i)
|
||||
{
|
||||
if (this.m_Target.DoesLayerSynchronizeTypeExist(i) == false)
|
||||
{
|
||||
this.m_Target.SetLayerSynchronized(i, PhotonAnimatorView.SynchronizeType.Disabled);
|
||||
}
|
||||
|
||||
PhotonAnimatorView.SynchronizeType syncType = this.m_Target.GetLayerSynchronizeType(i);
|
||||
|
||||
Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + i * lineHeight, containerRect.width, lineHeight);
|
||||
|
||||
Rect labelRect = new Rect(elementRect.xMin + 5, elementRect.yMin + 2, EditorGUIUtility.labelWidth - 5, elementRect.height);
|
||||
GUI.Label(labelRect, "Layer " + i);
|
||||
|
||||
Rect popupRect = new Rect(elementRect.xMin + EditorGUIUtility.labelWidth, elementRect.yMin + 2, elementRect.width - EditorGUIUtility.labelWidth - 5, EditorGUIUtility.singleLineHeight);
|
||||
syncType = (PhotonAnimatorView.SynchronizeType)EditorGUI.EnumPopup(popupRect, syncType);
|
||||
|
||||
if (i < this.GetLayerCount() - 1)
|
||||
{
|
||||
Rect splitterRect = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
|
||||
PhotonGUI.DrawSplitter(splitterRect);
|
||||
}
|
||||
|
||||
if (syncType != this.m_Target.GetLayerSynchronizeType(i))
|
||||
{
|
||||
Undo.RecordObject(this.target, "Modify Synchronize Layer Weights");
|
||||
this.m_Target.SetLayerSynchronized(i, syncType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool DoesParameterExist(string name)
|
||||
{
|
||||
for (int i = 0; i < this.GetParameterCount(); ++i)
|
||||
{
|
||||
if (this.GetAnimatorControllerParameter(i).name == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CheckIfStoredParametersExist()
|
||||
{
|
||||
var syncedParams = this.m_Target.GetSynchronizedParameters();
|
||||
List<string> paramsToRemove = new List<string>();
|
||||
|
||||
for (int i = 0; i < syncedParams.Count; ++i)
|
||||
{
|
||||
string parameterName = syncedParams[i].Name;
|
||||
if (this.DoesParameterExist(parameterName) == false)
|
||||
{
|
||||
Debug.LogWarning("Parameter '" + this.m_Target.GetSynchronizedParameters()[i].Name + "' doesn't exist anymore. Removing it from the list of synchronized parameters");
|
||||
paramsToRemove.Add(parameterName);
|
||||
}
|
||||
}
|
||||
|
||||
if (paramsToRemove.Count > 0)
|
||||
{
|
||||
foreach (string param in paramsToRemove)
|
||||
{
|
||||
this.m_Target.GetSynchronizedParameters().RemoveAll(item => item.Name == param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DrawParameterInspector()
|
||||
{
|
||||
// flag to expose a note in Interface if one or more trigger(s) are synchronized
|
||||
bool isUsingTriggers = false;
|
||||
|
||||
SerializedProperty foldoutProperty = this.serializedObject.FindProperty("ShowParameterInspector");
|
||||
foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Parameters", foldoutProperty.boolValue);
|
||||
|
||||
if (foldoutProperty.boolValue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float lineHeight = 20;
|
||||
Rect containerRect = PhotonGUI.ContainerBody(this.GetParameterCount() * lineHeight);
|
||||
|
||||
for (int i = 0; i < this.GetParameterCount(); i++)
|
||||
{
|
||||
AnimatorControllerParameter parameter = null;
|
||||
parameter = this.GetAnimatorControllerParameter(i);
|
||||
|
||||
string defaultValue = "";
|
||||
|
||||
if (parameter.type == AnimatorControllerParameterType.Bool)
|
||||
{
|
||||
if (Application.isPlaying && this.m_Animator.gameObject.activeInHierarchy)
|
||||
{
|
||||
defaultValue += this.m_Animator.GetBool(parameter.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultValue += parameter.defaultBool.ToString();
|
||||
}
|
||||
}
|
||||
else if (parameter.type == AnimatorControllerParameterType.Float)
|
||||
{
|
||||
if (Application.isPlaying && this.m_Animator.gameObject.activeInHierarchy)
|
||||
{
|
||||
defaultValue += this.m_Animator.GetFloat(parameter.name).ToString("0.00");
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultValue += parameter.defaultFloat.ToString();
|
||||
}
|
||||
}
|
||||
else if (parameter.type == AnimatorControllerParameterType.Int)
|
||||
{
|
||||
if (Application.isPlaying && this.m_Animator.gameObject.activeInHierarchy)
|
||||
{
|
||||
defaultValue += this.m_Animator.GetInteger(parameter.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultValue += parameter.defaultInt.ToString();
|
||||
}
|
||||
}
|
||||
else if (parameter.type == AnimatorControllerParameterType.Trigger)
|
||||
{
|
||||
if (Application.isPlaying && this.m_Animator.gameObject.activeInHierarchy)
|
||||
{
|
||||
defaultValue += this.m_Animator.GetBool(parameter.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultValue += parameter.defaultBool.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.m_Target.DoesParameterSynchronizeTypeExist(parameter.name) == false)
|
||||
{
|
||||
this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType)parameter.type, PhotonAnimatorView.SynchronizeType.Disabled);
|
||||
}
|
||||
|
||||
PhotonAnimatorView.SynchronizeType value = this.m_Target.GetParameterSynchronizeType(parameter.name);
|
||||
|
||||
// check if using trigger and actually synchronizing it
|
||||
if (value != PhotonAnimatorView.SynchronizeType.Disabled && parameter.type == AnimatorControllerParameterType.Trigger)
|
||||
{
|
||||
isUsingTriggers = true;
|
||||
}
|
||||
|
||||
Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + i * lineHeight, containerRect.width, lineHeight);
|
||||
|
||||
Rect labelRect = new Rect(elementRect.xMin + 5, elementRect.yMin + 2, EditorGUIUtility.labelWidth - 5, elementRect.height);
|
||||
GUI.Label(labelRect, parameter.name + " (" + defaultValue + ")");
|
||||
|
||||
Rect popupRect = new Rect(elementRect.xMin + EditorGUIUtility.labelWidth, elementRect.yMin + 2, elementRect.width - EditorGUIUtility.labelWidth - 5, EditorGUIUtility.singleLineHeight);
|
||||
value = (PhotonAnimatorView.SynchronizeType)EditorGUI.EnumPopup(popupRect, value);
|
||||
|
||||
if (i < this.GetParameterCount() - 1)
|
||||
{
|
||||
Rect splitterRect = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
|
||||
PhotonGUI.DrawSplitter(splitterRect);
|
||||
}
|
||||
|
||||
if (value != this.m_Target.GetParameterSynchronizeType(parameter.name))
|
||||
{
|
||||
Undo.RecordObject(this.target, "Modify Synchronize Parameter " + parameter.name);
|
||||
this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType)parameter.type, value);
|
||||
}
|
||||
}
|
||||
|
||||
// display note when synchronized triggers are detected.
|
||||
if (isUsingTriggers)
|
||||
{
|
||||
EditorGUILayout.HelpBox("When using triggers, make sure this component is last in the stack. " +
|
||||
"If you still experience issues, implement triggers as a regular RPC " +
|
||||
"or in custom IPunObservable component instead.", MessageType.Warning);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a3f61bade114730459f7ad45f5f292c1
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -0,0 +1,50 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// <copyright file="PhotonRigidbody2DViewEditor.cs" company="Exit Games GmbH">
|
||||
// PhotonNetwork Framework for Unity - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This is a custom editor for the PhotonRigidbody2DView component.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Photon.Pun
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CustomEditor(typeof (PhotonRigidbody2DView))]
|
||||
public class PhotonRigidbody2DViewEditor : MonoBehaviourPunEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Editing is disabled in play mode.", MessageType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
PhotonRigidbody2DView view = (PhotonRigidbody2DView)target;
|
||||
|
||||
view.m_TeleportEnabled = PhotonGUI.ContainerHeaderToggle("Enable teleport for large distances", view.m_TeleportEnabled);
|
||||
|
||||
if (view.m_TeleportEnabled)
|
||||
{
|
||||
Rect rect = PhotonGUI.ContainerBody(20.0f);
|
||||
view.m_TeleportIfDistanceGreaterThan = EditorGUI.FloatField(rect, "Teleport if distance greater than", view.m_TeleportIfDistanceGreaterThan);
|
||||
}
|
||||
|
||||
view.m_SynchronizeVelocity = PhotonGUI.ContainerHeaderToggle("Synchronize Velocity", view.m_SynchronizeVelocity);
|
||||
view.m_SynchronizeAngularVelocity = PhotonGUI.ContainerHeaderToggle("Synchronize Angular Velocity", view.m_SynchronizeAngularVelocity);
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3a82e8e86b9eecb40ac3f6ebc949f6ef
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -0,0 +1,50 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// <copyright file="PhotonRigidbodyViewEditor.cs" company="Exit Games GmbH">
|
||||
// PhotonNetwork Framework for Unity - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This is a custom editor for the RigidbodyView component.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Photon.Pun
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CustomEditor(typeof (PhotonRigidbodyView))]
|
||||
public class PhotonRigidbodyViewEditor : MonoBehaviourPunEditor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Editing is disabled in play mode.", MessageType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
PhotonRigidbodyView view = (PhotonRigidbodyView)target;
|
||||
|
||||
view.m_TeleportEnabled = PhotonGUI.ContainerHeaderToggle("Enable teleport for large distances", view.m_TeleportEnabled);
|
||||
|
||||
if (view.m_TeleportEnabled)
|
||||
{
|
||||
Rect rect = PhotonGUI.ContainerBody(20.0f);
|
||||
view.m_TeleportIfDistanceGreaterThan = EditorGUI.FloatField(rect, "Teleport if distance greater than", view.m_TeleportIfDistanceGreaterThan);
|
||||
}
|
||||
|
||||
view.m_SynchronizeVelocity = PhotonGUI.ContainerHeaderToggle("Synchronize Velocity", view.m_SynchronizeVelocity);
|
||||
view.m_SynchronizeAngularVelocity = PhotonGUI.ContainerHeaderToggle("Synchronize Angular Velocity", view.m_SynchronizeAngularVelocity);
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bcfebc9a2f1074488adedd1fe84e6c9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -0,0 +1,412 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// <copyright file="PhotonTransformViewClassicEditor.cs" company="Exit Games GmbH">
|
||||
// PhotonNetwork Framework for Unity - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This is a custom editor for the TransformView component.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Photon.Pun
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CustomEditor(typeof(PhotonTransformViewClassic))]
|
||||
public class PhotonTransformViewClassicEditor : MonoBehaviourPunEditor
|
||||
{
|
||||
//private PhotonTransformViewClassic m_Target;
|
||||
|
||||
private SerializedProperty m_SynchronizePositionProperty;
|
||||
private SerializedProperty m_SynchronizeRotationProperty;
|
||||
private SerializedProperty m_SynchronizeScaleProperty;
|
||||
|
||||
private bool m_InterpolateHelpOpen;
|
||||
private bool m_ExtrapolateHelpOpen;
|
||||
private bool m_InterpolateRotationHelpOpen;
|
||||
private bool m_InterpolateScaleHelpOpen;
|
||||
|
||||
private const int EDITOR_LINE_HEIGHT = 20;
|
||||
|
||||
private const string INTERPOLATE_TOOLTIP =
|
||||
"Choose between synchronizing the value directly (by disabling interpolation) or smoothly move it towards the newest update.";
|
||||
|
||||
private const string INTERPOLATE_HELP =
|
||||
"You can use interpolation to smoothly move your GameObject towards a new position that is received via the network. "
|
||||
+ "This helps to reduce the stuttering movement that results because the network updates only arrive 10 times per second.\n"
|
||||
+ "As a side effect, the GameObject is always lagging behind the actual position a little bit. This can be addressed with extrapolation.";
|
||||
|
||||
private const string EXTRAPOLATE_TOOLTIP = "Extrapolation is used to predict where the GameObject actually is";
|
||||
|
||||
private const string EXTRAPOLATE_HELP =
|
||||
"Whenever you deal with network values, all values you receive will be a little bit out of date since that data needs "
|
||||
+ "to reach you first. You can use extrapolation to try to predict where the player actually is, based on the movement data you have received.\n"
|
||||
+
|
||||
"This has to be tweaked carefully for each specific game in order to insure the optimal prediction. Sometimes it is very easy to extrapolate states, because "
|
||||
+
|
||||
"the GameObject behaves very predictable (for example for vehicles). Other times it can be very hard because the user input is translated directly to the game "
|
||||
+ "and you cannot really predict what the user is going to do (for example in fighting games)";
|
||||
|
||||
private const string INTERPOLATE_HELP_URL = "https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/package-demos/rpg-movement#interpolate_options";
|
||||
private const string EXTRAPOLATE_HELP_URL = "https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/package-demos/rpg-movement#extrapolate_options";
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
SetupSerializedProperties();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
base.OnInspectorGUI();
|
||||
|
||||
//this.m_Target = (PhotonTransformViewClassic) target;
|
||||
|
||||
DrawIsPlayingWarning();
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
|
||||
DrawSynchronizePositionHeader();
|
||||
DrawSynchronizePositionData();
|
||||
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
DrawSynchronizeRotationHeader();
|
||||
DrawSynchronizeRotationData();
|
||||
|
||||
GUI.enabled = !Application.isPlaying;
|
||||
DrawSynchronizeScaleHeader();
|
||||
DrawSynchronizeScaleData();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
GUI.enabled = true;
|
||||
}
|
||||
|
||||
private void DrawIsPlayingWarning()
|
||||
{
|
||||
if (Application.isPlaying == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GUILayout.BeginVertical(GUI.skin.box);
|
||||
{
|
||||
GUILayout.Label("Editing is disabled in play mode so the two objects don't go out of sync");
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
private void SetupSerializedProperties()
|
||||
{
|
||||
this.m_SynchronizePositionProperty = serializedObject.FindProperty("m_PositionModel.SynchronizeEnabled");
|
||||
this.m_SynchronizeRotationProperty = serializedObject.FindProperty("m_RotationModel.SynchronizeEnabled");
|
||||
this.m_SynchronizeScaleProperty = serializedObject.FindProperty("m_ScaleModel.SynchronizeEnabled");
|
||||
}
|
||||
|
||||
private void DrawSynchronizePositionHeader()
|
||||
{
|
||||
DrawHeader("Synchronize Position", this.m_SynchronizePositionProperty);
|
||||
}
|
||||
|
||||
private void DrawSynchronizePositionData()
|
||||
{
|
||||
if (this.m_SynchronizePositionProperty == null || this.m_SynchronizePositionProperty.boolValue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedProperty interpolatePositionProperty = serializedObject.FindProperty("m_PositionModel.InterpolateOption");
|
||||
PhotonTransformViewPositionModel.InterpolateOptions interpolateOption = (PhotonTransformViewPositionModel.InterpolateOptions)interpolatePositionProperty.enumValueIndex;
|
||||
|
||||
SerializedProperty extrapolatePositionProperty = serializedObject.FindProperty("m_PositionModel.ExtrapolateOption");
|
||||
PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption = (PhotonTransformViewPositionModel.ExtrapolateOptions)extrapolatePositionProperty.enumValueIndex;
|
||||
|
||||
float containerHeight = 155;
|
||||
|
||||
switch (interpolateOption)
|
||||
{
|
||||
case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
|
||||
case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
|
||||
containerHeight += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
/*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
|
||||
containerHeight += EDITOR_LINE_HEIGHT*3;
|
||||
break;*/
|
||||
}
|
||||
|
||||
if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
|
||||
{
|
||||
containerHeight += EDITOR_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
switch (extrapolateOption)
|
||||
{
|
||||
case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
|
||||
containerHeight += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.m_InterpolateHelpOpen == true)
|
||||
{
|
||||
containerHeight += GetInterpolateHelpBoxHeight();
|
||||
}
|
||||
|
||||
if (this.m_ExtrapolateHelpOpen == true)
|
||||
{
|
||||
containerHeight += GetExtrapolateHelpBoxHeight();
|
||||
}
|
||||
|
||||
// removed Gizmo Options. -3 lines, -1 splitter
|
||||
containerHeight -= EDITOR_LINE_HEIGHT * 3;
|
||||
|
||||
Rect rect = PhotonGUI.ContainerBody(containerHeight);
|
||||
|
||||
Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
DrawTeleport(ref propertyRect);
|
||||
DrawSplitter(ref propertyRect);
|
||||
|
||||
DrawSynchronizePositionDataInterpolation(ref propertyRect, interpolatePositionProperty, interpolateOption);
|
||||
DrawSplitter(ref propertyRect);
|
||||
|
||||
DrawSynchronizePositionDataExtrapolation(ref propertyRect, extrapolatePositionProperty, extrapolateOption);
|
||||
}
|
||||
|
||||
private float GetInterpolateHelpBoxHeight()
|
||||
{
|
||||
return PhotonGUI.RichLabel.CalcHeight(new GUIContent(INTERPOLATE_HELP), Screen.width - 54) + 35;
|
||||
}
|
||||
|
||||
private float GetExtrapolateHelpBoxHeight()
|
||||
{
|
||||
return PhotonGUI.RichLabel.CalcHeight(new GUIContent(EXTRAPOLATE_HELP), Screen.width - 54) + 35;
|
||||
}
|
||||
|
||||
private void DrawSplitter(ref Rect propertyRect)
|
||||
{
|
||||
Rect splitterRect = new Rect(propertyRect.xMin - 3, propertyRect.yMin, propertyRect.width + 6, 1);
|
||||
PhotonGUI.DrawSplitter(splitterRect);
|
||||
|
||||
propertyRect.y += 5;
|
||||
}
|
||||
|
||||
private void DrawHelpBox(ref Rect propertyRect, bool isOpen, float height, string helpText, string url)
|
||||
{
|
||||
if (isOpen == true)
|
||||
{
|
||||
Rect helpRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width, height - 5);
|
||||
GUI.BeginGroup(helpRect, GUI.skin.box);
|
||||
GUI.Label(new Rect(5, 5, propertyRect.width - 10, height - 30), helpText, PhotonGUI.RichLabel);
|
||||
if (GUI.Button(new Rect(5, height - 30, propertyRect.width - 10, 20), "Read more in our documentation"))
|
||||
{
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
GUI.EndGroup();
|
||||
|
||||
propertyRect.y += height;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPropertyWithHelpIcon(ref Rect propertyRect, ref bool isHelpOpen, SerializedProperty property, string tooltip)
|
||||
{
|
||||
Rect propertyFieldRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width - 20, propertyRect.height);
|
||||
string propertyName = ObjectNames.NicifyVariableName(property.name);
|
||||
EditorGUI.PropertyField(propertyFieldRect, property, new GUIContent(propertyName, tooltip));
|
||||
|
||||
Rect helpIconRect = new Rect(propertyFieldRect.xMax + 5, propertyFieldRect.yMin, 20, propertyFieldRect.height);
|
||||
isHelpOpen = GUI.Toggle(helpIconRect, isHelpOpen, PhotonGUI.HelpIcon, GUIStyle.none);
|
||||
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
private void DrawSynchronizePositionDataExtrapolation(ref Rect propertyRect, SerializedProperty extrapolatePositionProperty,
|
||||
PhotonTransformViewPositionModel.ExtrapolateOptions extrapolateOption)
|
||||
{
|
||||
DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_ExtrapolateHelpOpen, extrapolatePositionProperty, EXTRAPOLATE_TOOLTIP);
|
||||
DrawHelpBox(ref propertyRect, this.m_ExtrapolateHelpOpen, GetExtrapolateHelpBoxHeight(), EXTRAPOLATE_HELP, EXTRAPOLATE_HELP_URL);
|
||||
|
||||
if (extrapolateOption != PhotonTransformViewPositionModel.ExtrapolateOptions.Disabled)
|
||||
{
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.ExtrapolateIncludingRoundTripTime"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
switch (extrapolateOption)
|
||||
{
|
||||
case PhotonTransformViewPositionModel.ExtrapolateOptions.FixedSpeed:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.ExtrapolateSpeed"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawTeleport(ref Rect propertyRect)
|
||||
{
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.TeleportEnabled"),
|
||||
new GUIContent("Enable teleport for great distances"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.TeleportIfDistanceGreaterThan"),
|
||||
new GUIContent("Teleport if distance greater than"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
}
|
||||
|
||||
private void DrawSynchronizePositionDataInterpolation(ref Rect propertyRect, SerializedProperty interpolatePositionProperty,
|
||||
PhotonTransformViewPositionModel.InterpolateOptions interpolateOption)
|
||||
{
|
||||
DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateHelpOpen, interpolatePositionProperty, INTERPOLATE_TOOLTIP);
|
||||
DrawHelpBox(ref propertyRect, this.m_InterpolateHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
|
||||
|
||||
switch (interpolateOption)
|
||||
{
|
||||
case PhotonTransformViewPositionModel.InterpolateOptions.FixedSpeed:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsSpeed"),
|
||||
new GUIContent("MoveTowards Speed"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
|
||||
case PhotonTransformViewPositionModel.InterpolateOptions.Lerp:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
|
||||
/*case PhotonTransformViewPositionModel.InterpolateOptions.MoveTowardsComplex:
|
||||
Rect curveRect = new Rect(propertyRect.xMin, propertyRect.yMin, propertyRect.width - 100, propertyRect.height);
|
||||
EditorGUI.PropertyField(curveRect, serializedObject.FindProperty("m_PositionModel.InterpolateSpeedCurve"), new GUIContent("MoveTowards Speed Curve"));
|
||||
|
||||
Rect labelRect = new Rect(propertyRect.xMax - 95, propertyRect.yMin, 10, propertyRect.height);
|
||||
GUI.Label(labelRect, "x");
|
||||
|
||||
Rect multiplierRect = new Rect(propertyRect.xMax - 80, propertyRect.yMin, 80, propertyRect.height);
|
||||
EditorGUI.PropertyField(multiplierRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsSpeed"), GUIContent.none);
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsAcceleration"),
|
||||
new GUIContent("Acceleration"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_PositionModel.InterpolateMoveTowardsDeceleration"),
|
||||
new GUIContent("Deceleration"));
|
||||
propertyRect.y += EDITOR_LINE_HEIGHT;
|
||||
break;*/
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSynchronizeRotationHeader()
|
||||
{
|
||||
DrawHeader("Synchronize Rotation", this.m_SynchronizeRotationProperty);
|
||||
}
|
||||
|
||||
private void DrawSynchronizeRotationData()
|
||||
{
|
||||
if (this.m_SynchronizeRotationProperty == null || this.m_SynchronizeRotationProperty.boolValue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedProperty interpolateRotationProperty = serializedObject.FindProperty("m_RotationModel.InterpolateOption");
|
||||
PhotonTransformViewRotationModel.InterpolateOptions interpolateOption =
|
||||
(PhotonTransformViewRotationModel.InterpolateOptions)interpolateRotationProperty.enumValueIndex;
|
||||
|
||||
float containerHeight = 20;
|
||||
|
||||
switch (interpolateOption)
|
||||
{
|
||||
case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
|
||||
case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
|
||||
containerHeight += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.m_InterpolateRotationHelpOpen == true)
|
||||
{
|
||||
containerHeight += GetInterpolateHelpBoxHeight();
|
||||
}
|
||||
|
||||
Rect rect = PhotonGUI.ContainerBody(containerHeight);
|
||||
Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateRotationHelpOpen, interpolateRotationProperty, INTERPOLATE_TOOLTIP);
|
||||
DrawHelpBox(ref propertyRect, this.m_InterpolateRotationHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
|
||||
|
||||
switch (interpolateOption)
|
||||
{
|
||||
case PhotonTransformViewRotationModel.InterpolateOptions.RotateTowards:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_RotationModel.InterpolateRotateTowardsSpeed"),
|
||||
new GUIContent("RotateTowards Speed"));
|
||||
break;
|
||||
case PhotonTransformViewRotationModel.InterpolateOptions.Lerp:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_RotationModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSynchronizeScaleHeader()
|
||||
{
|
||||
DrawHeader("Synchronize Scale", this.m_SynchronizeScaleProperty);
|
||||
}
|
||||
|
||||
private void DrawSynchronizeScaleData()
|
||||
{
|
||||
if (this.m_SynchronizeScaleProperty == null || this.m_SynchronizeScaleProperty.boolValue == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedProperty interpolateScaleProperty = serializedObject.FindProperty("m_ScaleModel.InterpolateOption");
|
||||
PhotonTransformViewScaleModel.InterpolateOptions interpolateOption = (PhotonTransformViewScaleModel.InterpolateOptions)interpolateScaleProperty.enumValueIndex;
|
||||
|
||||
float containerHeight = EDITOR_LINE_HEIGHT;
|
||||
|
||||
switch (interpolateOption)
|
||||
{
|
||||
case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
|
||||
case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
|
||||
containerHeight += EDITOR_LINE_HEIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.m_InterpolateScaleHelpOpen == true)
|
||||
{
|
||||
containerHeight += GetInterpolateHelpBoxHeight();
|
||||
}
|
||||
|
||||
Rect rect = PhotonGUI.ContainerBody(containerHeight);
|
||||
Rect propertyRect = new Rect(rect.xMin + 5, rect.yMin + 2, rect.width - 10, EditorGUIUtility.singleLineHeight);
|
||||
|
||||
DrawPropertyWithHelpIcon(ref propertyRect, ref this.m_InterpolateScaleHelpOpen, interpolateScaleProperty, INTERPOLATE_TOOLTIP);
|
||||
DrawHelpBox(ref propertyRect, this.m_InterpolateScaleHelpOpen, GetInterpolateHelpBoxHeight(), INTERPOLATE_HELP, INTERPOLATE_HELP_URL);
|
||||
|
||||
switch (interpolateOption)
|
||||
{
|
||||
case PhotonTransformViewScaleModel.InterpolateOptions.MoveTowards:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateMoveTowardsSpeed"),
|
||||
new GUIContent("MoveTowards Speed"));
|
||||
break;
|
||||
case PhotonTransformViewScaleModel.InterpolateOptions.Lerp:
|
||||
EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_ScaleModel.InterpolateLerpSpeed"), new GUIContent("Lerp Speed"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHeader(string label, SerializedProperty property)
|
||||
{
|
||||
if (property == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool newValue = PhotonGUI.ContainerHeaderToggle(label, property.boolValue);
|
||||
|
||||
if (newValue != property.boolValue)
|
||||
{
|
||||
property.boolValue = newValue;
|
||||
property.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22292ca8ffb574945bedfaf49266672e
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
@ -0,0 +1,72 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// <copyright file="PhotonTransformViewEditor.cs" company="Exit Games GmbH">
|
||||
// PhotonNetwork Framework for Unity - Copyright (C) 2018 Exit Games GmbH
|
||||
// </copyright>
|
||||
// <summary>
|
||||
// This is a custom editor for the TransformView component.
|
||||
// </summary>
|
||||
// <author>developer@exitgames.com</author>
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace Photon.Pun
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
[CustomEditor(typeof(PhotonTransformView))]
|
||||
public class PhotonTransformViewEditor : Editor
|
||||
{
|
||||
private bool helpToggle = false;
|
||||
|
||||
SerializedProperty pos, rot, scl, lcl;
|
||||
|
||||
public void OnEnable()
|
||||
{
|
||||
pos = serializedObject.FindProperty("m_SynchronizePosition");
|
||||
rot = serializedObject.FindProperty("m_SynchronizeRotation");
|
||||
scl = serializedObject.FindProperty("m_SynchronizeScale");
|
||||
lcl = serializedObject.FindProperty("m_UseLocal");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
EditorGUILayout.HelpBox("Editing is disabled in play mode.", MessageType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
PhotonTransformView view = (PhotonTransformView)target;
|
||||
|
||||
|
||||
EditorGUILayout.LabelField("Synchronize Options");
|
||||
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
{
|
||||
EditorGUILayout.BeginVertical("HelpBox");
|
||||
{
|
||||
EditorGUILayout.PropertyField(pos, new GUIContent("Position", pos.tooltip));
|
||||
EditorGUILayout.PropertyField(rot, new GUIContent("Rotation", rot.tooltip));
|
||||
EditorGUILayout.PropertyField(scl, new GUIContent("Scale", scl.tooltip));
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.PropertyField(lcl, new GUIContent("Use Local", lcl.tooltip));
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
this.helpToggle = EditorGUILayout.Foldout(this.helpToggle, "Info");
|
||||
if (this.helpToggle)
|
||||
{
|
||||
EditorGUILayout.HelpBox("The Photon Transform View of PUN 2 is simple by design.\nReplace it with the Photon Transform View Classic if you want the old options.\nThe best solution is a custom IPunObservable implementation.", MessageType.Info, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8c9ec475ad103b43b901d942ff66e02
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user