void DrawNetworkGunsList() { GUILayout.Space(5); SerializedProperty listProperty = serializedObject.FindProperty(Dependency.GunListPropiertie); if (listProperty == null) { return; } float containerElementHeight = 22; float containerHeight = listProperty.arraySize * containerElementHeight; bool isOpen = PhotonGUI.ContainerHeaderFoldout("Networ Guns (" + GetGunsCount() + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue); serializedObject.FindProperty("ObservedComponentsFoldoutOpen").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); Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16); EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent()); Rect removeButtonRect = new Rect(elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth, elementRect.yMin + 2, PhotonGUI.DefaultRemoveButtonStyle.fixedWidth, PhotonGUI.DefaultRemoveButtonStyle.fixedHeight); GUI.enabled = listProperty.arraySize > 1; 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)); } serializedObject.ApplyModifiedProperties(); }
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 DrawWeightInspector() { SerializedProperty foldoutProperty = 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); #if !UNITY_MIN_5_3 EditorUtility.SetDirty(this.m_Target); #endif } 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(target, "Modify Synchronize Layer Weights"); this.m_Target.SetLayerSynchronized(i, syncType); #if !UNITY_MIN_5_3 EditorUtility.SetDirty(this.m_Target); #endif } } }
public override void OnInspectorGUI() { PhotonGUI.ContainerHeader("Options"); Rect containerRect = PhotonGUI.ContainerBody(EditorGUIUtility.singleLineHeight * 2 + 10); Rect propertyRect = new Rect(containerRect.xMin + 5, containerRect.yMin + 5, containerRect.width, EditorGUIUtility.singleLineHeight); EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeVelocity"), new GUIContent("Synchronize Velocity")); propertyRect.y += EditorGUIUtility.singleLineHeight; EditorGUI.PropertyField(propertyRect, serializedObject.FindProperty("m_SynchronizeAngularVelocity"), new GUIContent("Synchronize Angular Velocity")); }
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(); } }
private void DrawHeader(string label, SerializedProperty property) { if (property == null) { return; } bool newValue = PhotonGUI.ContainerHeaderToggle(label, property.boolValue); if (newValue != property.boolValue) { Undo.RecordObject(this.m_Target, "Change " + label); property.boolValue = newValue; EditorUtility.SetDirty(this.m_Target); } }
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 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); #if !UNITY_MIN_5_3 EditorUtility.SetDirty(this.m_Target); #endif } 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); #if !UNITY_MIN_5_3 EditorUtility.SetDirty(this.m_Target); #endif } } // 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"); if (GUILayout.Button(PhotonGUI.HelpIcon, GUIStyle.none, GUILayout.Width(16))) { Application.OpenURL(TRIGGER_HELP_URL); } GUILayout.EndHorizontal(); } }
private void DrawObservedComponentsList() { GUILayout.Space(5); SerializedProperty listProperty = serializedObject.FindProperty("ObservedComponents"); if (listProperty == null) { return; } float containerElementHeight = 22; float containerHeight = listProperty.arraySize * containerElementHeight; bool isOpen = PhotonGUI.ContainerHeaderFoldout("Observed Components (" + GetObservedComponentsCount() + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue); 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); EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent()); //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)); } 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; #if !UNITY_MIN_5_3 EditorUtility.SetDirty(this.m_Target); #endif serializedObject.Update(); } if (wasObservedComponentsEmpty == false && isObservedComponentsEmpty == true) { Undo.RecordObject(this.m_Target, "Change PhotonView"); this.m_Target.synchronization = ViewSynchronization.Off; #if !UNITY_MIN_5_3 EditorUtility.SetDirty(this.m_Target); #endif serializedObject.Update(); } }
private void DrawTeamsList() { GUILayout.Space(5); HashSet <byte> codes = new HashSet <byte>(); HashSet <string> names = new HashSet <string>(); for (int i = 0; i < teamsListSp.arraySize; i++) { SerializedProperty e = teamsListSp.GetArrayElementAtIndex(i); string name = e.FindPropertyRelative("Name").stringValue; byte code = (byte)e.FindPropertyRelative("Code").intValue; codes.Add(code); names.Add(name); } this.serializedObject.Update(); EditorGUI.BeginChangeCheck(); isOpen = PhotonGUI.ContainerHeaderFoldout(string.Format("Teams List ({0})", teamsListSp.arraySize), isOpen); if (EditorGUI.EndChangeCheck()) { listFoldIsOpenSp.boolValue = isOpen; } if (isOpen) { const float containerElementHeight = 22; const float propertyHeight = 16; const float paddingRight = 29; const float paddingLeft = 5; const float spacingY = 3; float containerHeight = (teamsListSp.arraySize + 1) * containerElementHeight; Rect containerRect = PhotonGUI.ContainerBody(containerHeight); float propertyWidth = containerRect.width - paddingRight; float codePropertyWidth = propertyWidth / 5; float namePropertyWidth = 4 * propertyWidth / 5; Rect elementRect = new Rect(containerRect.xMin, containerRect.yMin, containerRect.width, containerElementHeight); Rect propertyPosition = new Rect(elementRect.xMin + paddingLeft, elementRect.yMin + spacingY, codePropertyWidth, propertyHeight); EditorGUI.LabelField(propertyPosition, "Code"); Rect secondPropertyPosition = new Rect(elementRect.xMin + paddingLeft + codePropertyWidth, elementRect.yMin + spacingY, namePropertyWidth, propertyHeight); EditorGUI.LabelField(secondPropertyPosition, "Name"); for (int i = 0; i < teamsListSp.arraySize; ++i) { elementRect = new Rect(containerRect.xMin, containerRect.yMin + containerElementHeight * (i + 1), containerRect.width, containerElementHeight); propertyPosition = new Rect(elementRect.xMin + paddingLeft, elementRect.yMin + spacingY, codePropertyWidth, propertyHeight); SerializedProperty teamElementSp = teamsListSp.GetArrayElementAtIndex(i); SerializedProperty teamNameSp = teamElementSp.FindPropertyRelative("Name"); SerializedProperty teamCodeSp = teamElementSp.FindPropertyRelative("Code"); string oldName = teamNameSp.stringValue; byte oldCode = (byte)teamCodeSp.intValue; EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(propertyPosition, teamCodeSp, GUIContent.none); if (EditorGUI.EndChangeCheck()) { byte newCode = (byte)teamCodeSp.intValue; if (codes.Contains(newCode)) { Debug.LogWarningFormat("Team with the same code {0} already exists", newCode); teamCodeSp.intValue = oldCode; } } secondPropertyPosition = new Rect(elementRect.xMin + paddingLeft + codePropertyWidth, elementRect.yMin + spacingY, namePropertyWidth, propertyHeight); EditorGUI.BeginChangeCheck(); EditorGUI.PropertyField(secondPropertyPosition, teamNameSp, GUIContent.none); if (EditorGUI.EndChangeCheck()) { string newName = teamNameSp.stringValue; if (string.IsNullOrEmpty(newName)) { Debug.LogWarning("Team name cannot be null or empty"); teamNameSp.stringValue = oldName; } else if (names.Contains(newName)) { Debug.LogWarningFormat("Team with the same name \"{0}\" already exists", newName); teamNameSp.stringValue = oldName; } } Rect removeButtonRect = new Rect( elementRect.xMax - PhotonGUI.DefaultRemoveButtonStyle.fixedWidth, elementRect.yMin + 2, PhotonGUI.DefaultRemoveButtonStyle.fixedWidth, PhotonGUI.DefaultRemoveButtonStyle.fixedHeight); if (GUI.Button(removeButtonRect, new GUIContent(removeTexture), PhotonGUI.DefaultRemoveButtonStyle)) { teamsListSp.DeleteArrayElementAtIndex(i); } if (i < teamsListSp.arraySize - 1) { Rect texturePosition = new Rect(elementRect.xMin + 2, elementRect.yMax, elementRect.width - 4, 1); PhotonGUI.DrawSplitter(texturePosition); } } } if (PhotonGUI.AddButton()) { byte c = 0; while (codes.Contains(c) && c < byte.MaxValue) { c++; } this.teamsListSp.arraySize++; SerializedProperty teamElementSp = this.teamsListSp.GetArrayElementAtIndex(teamsListSp.arraySize - 1); SerializedProperty teamNameSp = teamElementSp.FindPropertyRelative("Name"); SerializedProperty teamCodeSp = teamElementSp.FindPropertyRelative("Code"); teamCodeSp.intValue = c; string n = "New Team"; int o = 1; while (names.Contains(n)) { n = string.Format("New Team {0}", o); o++; } teamNameSp.stringValue = n; } this.serializedObject.ApplyModifiedProperties(); }
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 * 2; 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); DrawSplitter(ref propertyRect); DrawSynchronizePositionDataGizmos(ref propertyRect); }
private void DrawParameterInspector() { 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) { defaultValue += parameter.defaultBool.ToString(); } else if (parameter.type == AnimatorControllerParameterType.Float) { defaultValue += parameter.defaultFloat.ToString(); } else if (parameter.type == AnimatorControllerParameterType.Int) { defaultValue += parameter.defaultInt.ToString(); } if (this.m_Target.DoesParameterSynchronizeTypeExist(parameter.name) == false) { this.m_Target.SetParameterSynchronized(parameter.name, (PhotonAnimatorView.ParameterType)parameter.type, PhotonAnimatorView.SynchronizeType.Disabled); EditorUtility.SetDirty(this.m_Target); } PhotonAnimatorView.SynchronizeType value = this.m_Target.GetParameterSynchronizeType(parameter.name); 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); EditorUtility.SetDirty(this.m_Target); } } }
public override void OnInspectorGUI() { serializedObject.Update(); bl_GunManager script = (bl_GunManager)target; bool allowSceneObjects = !EditorUtility.IsPersistent(script); EditorGUILayout.BeginVertical("box"); DrawNetworkGunsList(script); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); string[] weaponList = bl_GameData.Instance.AllWeaponStringList(); EditorGUILayout.BeginVertical("box"); ShowAssault = PhotonGUI.ContainerHeaderFoldout("Assault Class", ShowAssault); AssaultAnim.target = ShowAssault; if (EditorGUILayout.BeginFadeGroup(AssaultAnim.faded)) { script.m_AssaultClass.primary = EditorGUILayout.Popup("Primary", script.m_AssaultClass.primary, weaponList); script.m_AssaultClass.secondary = EditorGUILayout.Popup("Secondary", script.m_AssaultClass.secondary, weaponList); script.m_AssaultClass.Knife = EditorGUILayout.Popup("Knife", script.m_AssaultClass.Knife, weaponList); script.m_AssaultClass.Special = EditorGUILayout.Popup("Special", script.m_AssaultClass.Special, weaponList); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); ShowEngi = PhotonGUI.ContainerHeaderFoldout("Engineer Class", ShowEngi); EnginnerAnim.target = ShowEngi; if (EditorGUILayout.BeginFadeGroup(EnginnerAnim.faded)) { script.m_EngineerClass.primary = EditorGUILayout.Popup("Primary", script.m_EngineerClass.primary, weaponList); script.m_EngineerClass.secondary = EditorGUILayout.Popup("Secondary", script.m_EngineerClass.secondary, weaponList); script.m_EngineerClass.Knife = EditorGUILayout.Popup("Knife", script.m_EngineerClass.Knife, weaponList); script.m_EngineerClass.Special = EditorGUILayout.Popup("Special", script.m_EngineerClass.Special, weaponList); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); ShowRecon = PhotonGUI.ContainerHeaderFoldout("Recon Class", ShowRecon); ReconAnim.target = ShowRecon; if (EditorGUILayout.BeginFadeGroup(ReconAnim.faded)) { script.m_ReconClass.primary = EditorGUILayout.Popup("Primary", script.m_ReconClass.primary, weaponList); script.m_ReconClass.secondary = EditorGUILayout.Popup("Secondary", script.m_ReconClass.secondary, weaponList); script.m_ReconClass.Knife = EditorGUILayout.Popup("Knife", script.m_ReconClass.Knife, weaponList); script.m_ReconClass.Special = EditorGUILayout.Popup("Special", script.m_ReconClass.Special, weaponList); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.BeginVertical("box"); ShowSupport = PhotonGUI.ContainerHeaderFoldout("Support Class", ShowSupport); SupportAnim.target = ShowSupport; if (EditorGUILayout.BeginFadeGroup(SupportAnim.faded)) { script.m_SupportClass.primary = EditorGUILayout.Popup("Primary", script.m_SupportClass.primary, weaponList); script.m_SupportClass.secondary = EditorGUILayout.Popup("Secondary", script.m_SupportClass.secondary, weaponList); script.m_SupportClass.Knife = EditorGUILayout.Popup("Knife", script.m_SupportClass.Knife, weaponList); script.m_SupportClass.Special = EditorGUILayout.Popup("Special", script.m_SupportClass.Special, weaponList); } EditorGUILayout.EndFadeGroup(); EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); GUILayout.BeginVertical("box"); script.SwichTime = EditorGUILayout.Slider("Switch Time", script.SwichTime, 0.1f, 5); script.PickUpTime = EditorGUILayout.Slider("Pick Up Time", script.PickUpTime, 0.1f, 5); GUILayout.EndVertical(); GUILayout.BeginVertical("box"); script.HeadAnimator = EditorGUILayout.ObjectField("Head Animator", script.HeadAnimator, typeof(Animator), allowSceneObjects) as Animator; script.TrowPoint = EditorGUILayout.ObjectField("Throw Point", script.TrowPoint, typeof(Transform), allowSceneObjects) as Transform; script.SwitchFireAudioClip = EditorGUILayout.ObjectField("Switch Fire Mode Audio", script.SwitchFireAudioClip, typeof(AudioClip), allowSceneObjects) as AudioClip; GUILayout.EndVertical(); serializedObject.ApplyModifiedProperties(); }
void DrawNetworkGunsList(bl_GunManager script) { GUILayout.BeginHorizontal(); GUILayout.Label("WEAPON MANAGER", EditorStyles.toolbarButton); GUILayout.Space(5); if (GUILayout.Button(new GUIContent("IMPORT", EditorGUIUtility.IconContent("ol plus").image), EditorStyles.toolbarButton, GUILayout.Width(70))) { EditorWindow.GetWindow <bl_ImportExportWeapon>("Import", true).PrepareToImport(script.transform.root.GetComponent <bl_PlayerSync>(), null); } GUILayout.EndHorizontal(); SerializedProperty listProperty = serializedObject.FindProperty("AllGuns"); if (listProperty == null) { return; } float containerElementHeight = 22; float containerHeight = listProperty.arraySize * containerElementHeight; bool isOpen = PhotonGUI.ContainerHeaderFoldout("Gun List (" + script.AllGuns.Count + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue); serializedObject.FindProperty("ObservedComponentsFoldoutOpen").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); // MFPSEditorUtils.DrawTexture(texturePosition, MFPSEditorUtils.texGrabHandle); Rect propertyPosition = new Rect(elementRect.xMin + 20, elementRect.yMin + 3, elementRect.width - 45, 16); EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent()); 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(MFPSEditorUtils.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)); } serializedObject.ApplyModifiedProperties(); }
/*int GetGunsCount() * { * int count = 0; * * for (int i = 0; i < m_Target.NetworkGuns.Count; ++i) * { * if (m_Target.NetworkGuns[i] != null) * { * count++; * } * } * * return count; * }*/ void DrawNetworkGunsList() { GUILayout.Space(5); SerializedProperty listProperty = serializedObject.FindProperty("NetworkGuns"); if (listProperty == null) { return; } // float containerElementHeight = 22; //float containerHeight = listProperty.arraySize * containerElementHeight; /* bool isOpen = PhotonGUI.ContainerHeaderFoldout("Networ Guns (" + GetGunsCount() + ")", serializedObject.FindProperty("ObservedComponentsFoldoutOpen").boolValue); * serializedObject.FindProperty("ObservedComponentsFoldoutOpen").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); * EditorGUI.PropertyField(propertyPosition, listProperty.GetArrayElementAtIndex(i), new GUIContent()); * * 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)); } serializedObject.ApplyModifiedProperties(); }