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);
            }
        }
示例#2
0
        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;
            }
        }
示例#3
0
        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);
                }
            }
        }
示例#4
0
        private void DrawSceneSettingsList()
        {
            GUILayout.Space(5);

            // check for changes ( from undo for example)
            this.serializedObject.Update();

            listProperty = this.serializedObject.FindProperty("MinViewIdPerScene");

            if (listProperty == null)
            {
                return;
            }

            float containerElementHeight = 44;
            float containerHeight        = listProperty.arraySize * containerElementHeight;

            isOpen = PhotonGUI.ContainerHeaderFoldout("Scene Settings (" + listProperty.arraySize + ")",
                                                      this.serializedObject.FindProperty("SceneSettingsListFoldoutOpen").boolValue);
            this.serializedObject.FindProperty("SceneSettingsListFoldoutOpen").boolValue = isOpen;

            if (isOpen == false)
            {
                containerHeight = 0;
            }

            Rect containerRect = PhotonGUI.ContainerBody(containerHeight);

            if (isOpen == true)
            {
                for (int i = 0; i < listProperty.arraySize; ++i)
                {
                    Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * i,
                                                containerRect.width, containerElementHeight);
                    {
                        Rect texturePosition = new Rect(elementRect.xMin + 6,
                                                        elementRect.yMin + elementRect.height / 2f - 1, 9, 5);
                        ReorderableListResources.DrawTexture(texturePosition, ReorderableListResources.texGrabHandle);

                        Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3,
                                                         elementRect.width - 45, 16);

                        _sceneSettings_i = listProperty.GetArrayElementAtIndex(i);

                        sceneNameProperty  = _sceneSettings_i.FindPropertyRelative("sceneName");
                        sceneAssetProperty = _sceneSettings_i.FindPropertyRelative("sceneAsset");
                        minViewIdProperty  = _sceneSettings_i.FindPropertyRelative("minViewId");

                        string     _sceneName  = sceneNameProperty.stringValue;
                        SceneAsset _sceneAsset = m_Target.MinViewIdPerScene[i].sceneAsset;

                        // check if we need to find the scene asset based on the scene name. This is for backward compatibility or when the scene asset was deleted
                        if (_firstTime)
                        {
                            if (_sceneAsset == null && !string.IsNullOrEmpty(_sceneName))
                            {
                                string[] guids = AssetDatabase.FindAssets(_sceneName + " t:SceneAsset");

                                foreach (string guid in guids)
                                {
                                    string path = AssetDatabase.GUIDToAssetPath(guid);
                                    if (Path.GetFileNameWithoutExtension(path) == _sceneName)
                                    {
                                        sceneAssetProperty.objectReferenceValue =
                                            AssetDatabase.LoadAssetAtPath <SceneAsset>(
                                                AssetDatabase.GUIDToAssetPath(guid));
                                        break;
                                    }
                                }
                            }
                        }

                        bool _missingSceneAsset = _sceneAsset == null && !string.IsNullOrEmpty(_sceneName);
                        // if we don't have a scene asset for the serialized scene named, we show an error.
                        if (_missingSceneAsset ||
                            (sceneNameProperty != null && _duplicateScenesDefinition != null &&
                             _duplicateScenesDefinition.Contains(sceneNameProperty.stringValue))
                            )
                        {
                            GUI.color = Color.red;
                        }

                        EditorGUI.BeginChangeCheck();
                        string _label = _missingSceneAsset
                            ? "Scene Asset: Missing '" + _sceneName + "'"
                            : "Scene Asset";

                        EditorGUI.PropertyField(propertyPosition, sceneAssetProperty, new GUIContent(_label));

                        if (EditorGUI.EndChangeCheck())
                        {
                            _sceneAsset = sceneAssetProperty.objectReferenceValue as SceneAsset;
                            if (_sceneAsset == null && !string.IsNullOrEmpty(sceneNameProperty.stringValue))
                            {
                                sceneNameProperty.stringValue = null;
                            }
                            else if (sceneNameProperty.stringValue != _sceneAsset.name)
                            {
                                sceneNameProperty.stringValue = _sceneAsset.name;
                            }
                        }


                        // EditorGUI.PropertyField(propertyPosition,  sceneNameProperty,
                        //    new GUIContent("Scene Name"));

                        GUI.color = Color.white;

                        if (minViewIdProperty.intValue < 1 || minViewIdProperty.intValue > PhotonNetwork.MAX_VIEW_IDS)
                        {
                            GUI.color = Color.red;
                        }

                        Rect secondPropertyPosition = new Rect(elementRect.xMin + 20,
                                                               elementRect.yMin + containerElementHeight / 2,
                                                               elementRect.width - 45, 16);

                        EditorGUI.PropertyField(secondPropertyPosition,
                                                _sceneSettings_i.FindPropertyRelative("minViewId"),
                                                new GUIContent("Minimum View ID"));

                        GUI.color = Color.white;

                        //Debug.Log( listProperty.GetArrayElementAtIndex( i ).objectReferenceValue.GetType() );
                        //Rect statsPosition = new Rect( propertyPosition.xMax + 7, propertyPosition.yMin, statsIcon.width, statsIcon.height );
                        //ReorderableListResources.DrawTexture( statsPosition, statsIcon );


                        Rect removeButtonRect = new Rect(
                            elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                            elementRect.yMin + 2,
                            PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                            PhotonGUI.DefaultRemoveButtonStyle.fixedHeight);


                        if (GUI.Button(removeButtonRect, new GUIContent(ReorderableListResources.texRemoveButton),
                                       PhotonGUI.DefaultRemoveButtonStyle))
                        {
                            listProperty.DeleteArrayElementAtIndex(i);

                            Undo.RecordObject(this.m_Target, "Removed SceneSettings Entry");
                        }


                        if (i < listProperty.arraySize - 1)
                        {
                            texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4,
                                                       1);
                            PhotonGUI.DrawSplitter(texturePosition);
                        }
                    }
                }
            }

            if (PhotonGUI.AddButton())
            {
                this.listProperty.InsertArrayElementAtIndex(Mathf.Max(0, listProperty.arraySize - 1));
                _sceneSettings_i   = this.listProperty.GetArrayElementAtIndex(listProperty.arraySize - 1);
                sceneNameProperty  = _sceneSettings_i.FindPropertyRelative("sceneName");
                sceneAssetProperty = _sceneSettings_i.FindPropertyRelative("sceneAsset");
                minViewIdProperty  = _sceneSettings_i.FindPropertyRelative("minViewId");

                sceneAssetProperty.objectReferenceValue = null;
                sceneNameProperty.stringValue           = "";
                minViewIdProperty.intValue = 1;

                Undo.RecordObject(this.m_Target, "Added SceneSettings Entry");
            }

            this.serializedObject.ApplyModifiedProperties();
        }
示例#5
0
        private void DrawObservedComponentsList()
        {
            GUILayout.Space(5);
            SerializedProperty listProperty = this.serializedObject.FindProperty("ObservedComponents");

            if (listProperty == null)
            {
                return;
            }

            float containerElementHeight = 22;
            float containerHeight        = listProperty.arraySize * containerElementHeight;

            bool isOpen = PhotonGUI.ContainerHeaderFoldout("Observed Components (" + this.GetObservedComponentsCount() + ")", this.serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue);

            this.serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue = isOpen;

            if (isOpen == false)
            {
                containerHeight = 0;
            }

            //Texture2D statsIcon = AssetDatabase.LoadAssetAtPath( "Assets/Photon Unity Networking/Editor/PhotonNetwork/PhotonViewStats.png", typeof( Texture2D ) ) as Texture2D;

            Rect containerRect = PhotonGUI.ContainerBody(containerHeight);
            bool wasObservedComponentsEmpty = this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0;

            if (isOpen == true)
            {
                for (int i = 0; i < listProperty.arraySize; ++i)
                {
                    Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * i, containerRect.width, containerElementHeight);
                    {
                        Rect texturePosition = new Rect(elementRect.xMin + 6, elementRect.yMin + elementRect.height / 2f - 1, 9, 5);
                        ReorderableListResources.DrawTexture(texturePosition, ReorderableListResources.texGrabHandle);

                        Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16);

                        // keep track of old type to catch when a new type is observed
                        Type _oldType = listProperty.GetArrayElementAtIndex(i).objectReferenceValue != null?listProperty.GetArrayElementAtIndex(i).objectReferenceValue.GetType() : null;

                        EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent());

                        // new type, could be different from old type
                        Type _newType = listProperty.GetArrayElementAtIndex(i).objectReferenceValue != null?listProperty.GetArrayElementAtIndex(i).objectReferenceValue.GetType() : null;

                        // the user dropped a Transform, we must change it by adding a PhotonTransformView and observe that instead
                        if (_oldType != _newType)
                        {
                            if (_newType == typeof(PhotonView))
                            {
                                listProperty.GetArrayElementAtIndex(i).objectReferenceValue = null;
                                Debug.LogError("PhotonView Detected you dropped a PhotonView, this is not allowed. \n It's been removed from observed field.");
                            }
                            else if (_newType == typeof(Transform))
                            {
                                // try to get an existing PhotonTransformView ( we don't want any duplicates...)
                                PhotonTransformView _ptv = this.m_Target.gameObject.GetComponent <PhotonTransformView>();
                                if (_ptv == null)
                                {
                                    // no ptv yet, we create one and enable position and rotation, no scaling, as it's too rarely needed to take bandwidth for nothing
                                    _ptv = Undo.AddComponent <PhotonTransformView>(this.m_Target.gameObject);
                                }
                                // switch observe from transform to _ptv
                                listProperty.GetArrayElementAtIndex(i).objectReferenceValue = _ptv;
                                Debug.Log("PhotonView has detected you dropped a Transform. Instead it's better to observe a PhotonTransformView for better control and performances");
                            }
                            else if (_newType == typeof(Rigidbody))
                            {
                                Rigidbody _rb = listProperty.GetArrayElementAtIndex(i).objectReferenceValue as Rigidbody;

                                // try to get an existing PhotonRigidbodyView ( we don't want any duplicates...)
                                PhotonRigidbodyView _prbv = _rb.gameObject.GetComponent <PhotonRigidbodyView>();
                                if (_prbv == null)
                                {
                                    // no _prbv yet, we create one
                                    _prbv = Undo.AddComponent <PhotonRigidbodyView>(_rb.gameObject);
                                }
                                // switch observe from transform to _prbv
                                listProperty.GetArrayElementAtIndex(i).objectReferenceValue = _prbv;
                                Debug.Log("PhotonView has detected you dropped a RigidBody. Instead it's better to observe a PhotonRigidbodyView for better control and performances");
                            }
                            else if (_newType == typeof(Rigidbody2D))
                            {
                                // try to get an existing PhotonRigidbody2DView ( we don't want any duplicates...)
                                PhotonRigidbody2DView _prb2dv = this.m_Target.gameObject.GetComponent <PhotonRigidbody2DView>();
                                if (_prb2dv == null)
                                {
                                    // no _prb2dv yet, we create one
                                    _prb2dv = Undo.AddComponent <PhotonRigidbody2DView>(this.m_Target.gameObject);
                                }
                                // switch observe from transform to _prb2dv
                                listProperty.GetArrayElementAtIndex(i).objectReferenceValue = _prb2dv;
                                Debug.Log("PhotonView has detected you dropped a Rigidbody2D. Instead it's better to observe a PhotonRigidbody2DView for better control and performances");
                            }
                            else if (_newType == typeof(Animator))
                            {
                                // try to get an existing PhotonAnimatorView ( we don't want any duplicates...)
                                PhotonAnimatorView _pav = this.m_Target.gameObject.GetComponent <PhotonAnimatorView>();
                                if (_pav == null)
                                {
                                    // no _pav yet, we create one
                                    _pav = Undo.AddComponent <PhotonAnimatorView>(this.m_Target.gameObject);
                                }
                                // switch observe from transform to _prb2dv
                                listProperty.GetArrayElementAtIndex(i).objectReferenceValue = _pav;
                                Debug.Log("PhotonView has detected you dropped a Animator, so we switched to PhotonAnimatorView so that you can serialized the Animator variables");
                            }
                            else if (!typeof(IPunObservable).IsAssignableFrom(_newType))
                            {
                                bool _ignore = false;
                                #if PLAYMAKER
                                _ignore = _newType == typeof(PlayMakerFSM);// Photon Integration for PlayMaker will swap at runtime to a proxy using iPunObservable.
                                #endif

                                if (_newType == null || _newType == typeof(Rigidbody) || _newType == typeof(Rigidbody2D))
                                {
                                    _ignore = true;
                                }

                                if (!_ignore)
                                {
                                    listProperty.GetArrayElementAtIndex(i).objectReferenceValue = null;
                                    Debug.LogError("PhotonView Detected you dropped a Component missing IPunObservable Interface,\n You dropped a <" + _newType + "> instead. It's been removed from observed field.");
                                }
                            }
                        }

                        //Debug.Log( listProperty.GetArrayElementAtIndex( i ).objectReferenceValue.GetType() );
                        //Rect statsPosition = new Rect( propertyPosition.xMax + 7, propertyPosition.yMin, statsIcon.width, statsIcon.height );
                        //ReorderableListResources.DrawTexture( statsPosition, statsIcon );

                        Rect removeButtonRect = new Rect(elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                         elementRect.yMin + 2,
                                                         PhotonGUI.DefaultRemoveButtonStyle.fixedWidth,
                                                         PhotonGUI.DefaultRemoveButtonStyle.fixedHeight);

                        GUI.enabled = listProperty.arraySize > 1;
                        if (GUI.Button(removeButtonRect, new GUIContent(ReorderableListResources.texRemoveButton), PhotonGUI.DefaultRemoveButtonStyle))
                        {
                            listProperty.DeleteArrayElementAtIndex(i);
                        }
                        GUI.enabled = true;

                        if (i < listProperty.arraySize - 1)
                        {
                            texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1);
                            PhotonGUI.DrawSplitter(texturePosition);
                        }
                    }
                }
            }

            if (PhotonGUI.AddButton())
            {
                listProperty.InsertArrayElementAtIndex(Mathf.Max(0, listProperty.arraySize - 1));
            }

            this.serializedObject.ApplyModifiedProperties();

            bool isObservedComponentsEmpty = this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0;

            if (wasObservedComponentsEmpty == true && isObservedComponentsEmpty == false && this.m_Target.Synchronization == ViewSynchronization.Off)
            {
                Undo.RecordObject(this.m_Target, "Change PhotonView");
                this.m_Target.Synchronization = ViewSynchronization.UnreliableOnChange;
                this.serializedObject.Update();
            }

            if (wasObservedComponentsEmpty == false && isObservedComponentsEmpty == true)
            {
                Undo.RecordObject(this.m_Target, "Change PhotonView");
                this.m_Target.Synchronization = ViewSynchronization.Off;
                this.serializedObject.Update();
            }
        }
示例#6
0
        private void DrawParameterInspector()
        {
            // flag to expose a note in Interface if one or more trigger(s) are synchronized
            bool isUsingTriggers = false;

            SerializedProperty foldoutProperty = serializedObject.FindProperty("ShowParameterInspector");

            foldoutProperty.boolValue = PhotonGUI.ContainerHeaderFoldout("Synchronize Parameters", foldoutProperty.boolValue);

            if (foldoutProperty.boolValue == false)
            {
                return;
            }

            float lineHeight    = 20;
            Rect  containerRect = PhotonGUI.ContainerBody(GetParameterCount() * lineHeight);

            for (int i = 0; i < GetParameterCount(); i++)
            {
                AnimatorControllerParameter parameter = null;
                parameter = GetAnimatorControllerParameter(i);

                string defaultValue = "";

                if (parameter.type == AnimatorControllerParameterType.Bool)
                {
                    if (Application.isPlaying && m_Animator.gameObject.activeInHierarchy)
                    {
                        defaultValue += m_Animator.GetBool(parameter.name);
                    }
                    else
                    {
                        defaultValue += parameter.defaultBool.ToString();
                    }
                }
                else if (parameter.type == AnimatorControllerParameterType.Float)
                {
                    if (Application.isPlaying && m_Animator.gameObject.activeInHierarchy)
                    {
                        defaultValue += m_Animator.GetFloat(parameter.name).ToString("0.00");
                    }
                    else
                    {
                        defaultValue += parameter.defaultFloat.ToString();
                    }
                }
                else if (parameter.type == AnimatorControllerParameterType.Int)
                {
                    if (Application.isPlaying && m_Animator.gameObject.activeInHierarchy)
                    {
                        defaultValue += m_Animator.GetInteger(parameter.name);
                    }
                    else
                    {
                        defaultValue += parameter.defaultInt.ToString();
                    }
                }
                else if (parameter.type == AnimatorControllerParameterType.Trigger)
                {
                    if (Application.isPlaying && m_Animator.gameObject.activeInHierarchy)
                    {
                        defaultValue += 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 < 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(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)
            {
                GUILayout.BeginHorizontal(GUI.skin.box);
                GUILayout.Label("When using triggers, make sure this component is last in the stack");
                GUILayout.EndHorizontal();
            }
        }
示例#7
0
        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);
        }