Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Assets/FishNet/CodeGenerating/Unity.FishNet.CodeGen.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"references": [
"FishNet.Runtime",
"FishNet.Codegen.Cecil",
"GameKit.Dependencies"
"GameKit.Dependencies",
"Unity.Burst",
"Unity.Mathematics",
"Unity.Collections"
],
"includePlatforms": [
"Editor"
Expand Down
4 changes: 3 additions & 1 deletion Assets/FishNet/Runtime/FishNet.Runtime.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"references": [
"GUID:894a6cc6ed5cd2645bb542978cbed6a9",
"GUID:1d82bdf40e2465b44b34adf79595e74c",
"GUID:d8b63aba1907145bea998dd612889d6b"
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:2665a8d13d1b3f18800f46e256720795",
"GUID:e0cd26848372d4e5c891c569017e11f1"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#if UNITY_EDITOR
using FishNet.Object;
using GameKit.Dependencies.Utilities;
using UnityEditor;
using UnityEngine;

namespace FishNet.Component.Transforming.Beta.Editing
{
#if THREADED_TICKSMOOTHERS
[CustomPropertyDrawer(typeof(MovementSettings))]
public class MovementSettingsDrawer : PropertyDrawer
{
private PropertyDrawerTool _propertyDrawer;

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);

_propertyDrawer = new(position);

// _propertyDrawer.DrawLabel(label, FontStyle.Bold);

EditorGUI.indentLevel++;

SerializedProperty enableTeleport = property.FindPropertyRelative("EnableTeleport");
SerializedProperty teleportThreshold = property.FindPropertyRelative("TeleportThreshold");
SerializedProperty adaptiveInterpolationValue = property.FindPropertyRelative("AdaptiveInterpolationValue");
SerializedProperty interpolationValue = property.FindPropertyRelative("InterpolationValue");
SerializedProperty smoothedProperties = property.FindPropertyRelative("SmoothedProperties");
SerializedProperty snapNonSmoothedProperties = property.FindPropertyRelative("SnapNonSmoothedProperties");

_propertyDrawer.DrawProperty(enableTeleport, "Enable Teleport");
if (enableTeleport.boolValue == true)
_propertyDrawer.DrawProperty(teleportThreshold, "Teleport Threshold", indent: 1);

_propertyDrawer.DrawProperty(adaptiveInterpolationValue, "Adaptive Interpolation");
if ((AdaptiveInterpolationType)adaptiveInterpolationValue.intValue == AdaptiveInterpolationType.Off)
_propertyDrawer.DrawProperty(interpolationValue, "Interpolation Value", indent: 1);

_propertyDrawer.DrawProperty(smoothedProperties, "Smoothed Properties");
if ((uint)smoothedProperties.intValue != (uint)TransformPropertiesFlag.Everything)
_propertyDrawer.DrawProperty(snapNonSmoothedProperties, "Snap Non-Smoothed Properties", indent: 1);

_propertyDrawer.SetIndentToStarting();

EditorGUI.EndProperty();
}

public override float GetPropertyHeight(SerializedProperty property, GUIContent label) => _propertyDrawer.GetPropertyHeight();
}
#endif
}
#endif

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace FishNet.Component.Transforming.Beta.Editing
{
#if !THREADED_TICKSMOOTHERS
[CustomPropertyDrawer(typeof(MovementSettings))]
public class MovementSettingsDrawer : PropertyDrawer
{
Expand All @@ -26,6 +27,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
SerializedProperty adaptiveInterpolationValue = property.FindPropertyRelative("AdaptiveInterpolationValue");
SerializedProperty interpolationValue = property.FindPropertyRelative("InterpolationValue");
SerializedProperty smoothedProperties = property.FindPropertyRelative("SmoothedProperties");
SerializedProperty useLocalSpace = property.FindPropertyRelative("UseLocalSpace");
SerializedProperty snapNonSmoothedProperties = property.FindPropertyRelative("SnapNonSmoothedProperties");

_propertyDrawer.DrawProperty(enableTeleport, "Enable Teleport");
Expand All @@ -37,6 +39,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
_propertyDrawer.DrawProperty(interpolationValue, "Interpolation Value", indent: 1);

_propertyDrawer.DrawProperty(smoothedProperties, "Smoothed Properties");
_propertyDrawer.DrawProperty(useLocalSpace, "Use Local Space");
if ((uint)smoothedProperties.intValue != (uint)TransformPropertiesFlag.Everything)
_propertyDrawer.DrawProperty(snapNonSmoothedProperties, "Snap Non-Smoothed Properties", indent: 1);

Expand All @@ -47,5 +50,6 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

public override float GetPropertyHeight(SerializedProperty property, GUIContent label) => _propertyDrawer.GetPropertyHeight();
}
#endif
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void OnInspectorGUI()
EditorGUILayout.ObjectField("Script:", MonoScript.FromMonoBehaviour((NetworkTickSmoother)target), typeof(NetworkTickSmoother), false);
GUI.enabled = true;

EditorGUILayout.PropertyField(_favorPredictionNetworkTransform);
EditorGUILayout.LabelField("Initialization Settings", EditorStyles.boldLabel);

EditorGUILayout.PropertyField(_initializationSettings);

Expand All @@ -45,7 +45,6 @@ public override void OnInspectorGUI()
EditorGUILayout.PropertyField(_spectatorMovementSettings);
}


// EditorGUI.indentLevel--;

serializedObject.ApplyModifiedProperties();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using FishNet.Object;
using UnityEngine;

namespace FishNet.Component.Transforming.Beta
{
#if THREADED_TICKSMOOTHERS
[System.Serializable]
public struct MovementSettings
{
/// <summary>
/// True to enable teleport threshold.
/// </summary>
[Tooltip("True to enable teleport threshold.")]
public bool EnableTeleport;
/// <summary>
/// How far the object must move between ticks to teleport rather than smooth.
/// </summary>
[Tooltip("How far the object must move between ticks to teleport rather than smooth.")]
[Range(0f, ushort.MaxValue)]
public float TeleportThreshold;
/// <summary>
/// Amount of adaptive interpolation to use. Adaptive interpolation increases interpolation with the local client's latency. Lower values of adaptive interpolation results in smaller interpolation increases.
/// In most cases adaptive interpolation is only used with prediction where objects might be affected by other moving objects.
/// </summary>
[Tooltip("Amount of adaptive interpolation to use. Adaptive interpolation increases interpolation with the local client's latency. Lower values of adaptive interpolation results in smaller interpolation increases. In most cases adaptive interpolation is only used with prediction where objects might be affected by other moving objects.")]
public AdaptiveInterpolationType AdaptiveInterpolationValue;
/// <summary>
/// Number of ticks to smooth over when not using adaptive interpolation.
/// </summary>
[Tooltip("Number of ticks to smooth over when not using adaptive interpolation.")]
public byte InterpolationValue;
/// <summary>
/// Properties to smooth. Any value not selected will become offset with every movement.
/// </summary>
[Tooltip("Properties to smooth. Any value not selected will become offset with every movement.")]
public TransformPropertiesFlag SmoothedProperties;
/// <summary>
/// True to apply smoothing in local space for position and rotation. False to use world space.
/// </summary>
[Tooltip("True to apply smoothing in local space for position and rotation. False to use world space.")]
public bool UseLocalSpace;
/// <summary>
/// True to keep non-smoothed properties at their original localspace every tick. A false value will keep the properties in the same world space as they were before each tick.
/// </summary>
[Tooltip("True to keep non-smoothed properties at their original localspace every tick. A false value will keep the properties in the same world space as they were before each tick.")]
public bool SnapNonSmoothedProperties;

public MovementSettings(bool unityReallyNeedsToSupportParameterlessInitializersOnStructsAlready)
{
EnableTeleport = false;
TeleportThreshold = 0f;
AdaptiveInterpolationValue = AdaptiveInterpolationType.Off;
InterpolationValue = 2;
SmoothedProperties = TransformPropertiesFlag.Everything;
UseLocalSpace = false;
SnapNonSmoothedProperties = false;
}
}
#endif
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace FishNet.Component.Transforming.Beta
{
#if !THREADED_TICKSMOOTHERS
[System.Serializable]
public struct MovementSettings
{
Expand Down Expand Up @@ -49,4 +50,5 @@ public MovementSettings(bool unityReallyNeedsToSupportParameterlessInitializersO
SnapNonSmoothedProperties = false;
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using FishNet.Object;
using GameKit.Dependencies.Utilities;
using UnityEngine;
using UnityEngine.Serialization;

namespace FishNet.Component.Transforming.Beta
{
Expand Down Expand Up @@ -53,7 +52,7 @@ private void OnDestroy()
public override void OnStartClient()
{
RetrieveControllers();

_initializationSettings.SetNetworkedRuntimeValues(initializingNetworkBehaviour: this, graphicalTransform: transform, _favorPredictionNetworkTransform);
SmootherController.Initialize(_initializationSettings, _controllerMovementSettings, _spectatorMovementSettings);

Expand Down
Loading