You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
3.9 KiB
C#
104 lines
3.9 KiB
C#
2 weeks ago
|
//Shady
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using Fusion.Editor;
|
||
|
using UnityEditor;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace Fusion.Addons.SimpleKCC.Editor
|
||
|
{
|
||
|
[InitializeOnLoad]
|
||
|
[CustomEditor(typeof(KCCOffline), true)]
|
||
|
public class KCCOfflineEditor : UnityEditor.Editor
|
||
|
{
|
||
|
private const string SETTINGS_PROPERTY_NAME = "_settings";
|
||
|
|
||
|
private const string INTERPOLATION_DATA_SOURCE_PROPERTY_NAME = "_interpolationDataSource";
|
||
|
|
||
|
private static string[] _excludedProperties = new string[2] { "_settings", "_interpolationDataSource" };
|
||
|
|
||
|
private static bool _resetTools = false;
|
||
|
|
||
|
[InitializeOnLoadMethod]
|
||
|
private static void Initialize()
|
||
|
{
|
||
|
Selection.selectionChanged = (Action)Delegate.Remove(Selection.selectionChanged, new Action(OnSelectionChanged));
|
||
|
Selection.selectionChanged = (Action)Delegate.Combine(Selection.selectionChanged, new Action(OnSelectionChanged));
|
||
|
static void OnSelectionChanged()
|
||
|
{
|
||
|
if (_resetTools)
|
||
|
{
|
||
|
_resetTools = false;
|
||
|
Tools.hidden = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void OnSceneGUI()
|
||
|
{
|
||
|
_resetTools = true;
|
||
|
if (!Application.isPlaying)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
KCCOffline kCC = base.target as KCCOffline;
|
||
|
if (kCC == null)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// if (Tools.current == Tool.Move)
|
||
|
// {
|
||
|
// Tools.hidden = true;
|
||
|
// Vector3 position = kCC.Transform.position;
|
||
|
// Vector3 targetPosition = Handles.PositionHandle(position, kCC.Transform.rotation);
|
||
|
// if (!targetPosition.Equals(position))
|
||
|
// {
|
||
|
// // kCC.FixedData.TargetPosition = targetPosition;
|
||
|
// // kCC.RenderData.TargetPosition = targetPosition;
|
||
|
// // kCC.SynchronizeTransform(synchronizePosition: true, synchronizeRotation: false, allowAntiJitter: false);
|
||
|
// }
|
||
|
// }
|
||
|
// else if (Tools.current == Tool.Rotate)
|
||
|
// {
|
||
|
// Tools.hidden = true;
|
||
|
// Quaternion rotation = kCC.Transform.rotation;
|
||
|
// Quaternion quaternion = Handles.RotationHandle(rotation, kCC.Transform.position);
|
||
|
// if (!quaternion.Equals(rotation))
|
||
|
// {
|
||
|
// Vector3 eulerAngles = (Quaternion.Inverse(rotation) * quaternion).eulerAngles;
|
||
|
// if (eulerAngles.y != 0f)
|
||
|
// {
|
||
|
// // kCC.Data.AddLookRotation(0f, eulerAngles.y);
|
||
|
// // float lookYaw = kCC.Data.LookYaw;
|
||
|
// // kCC.FixedData.LookYaw = lookYaw;
|
||
|
// // kCC.RenderData.LookYaw = lookYaw;
|
||
|
// // kCC.SynchronizeTransform(synchronizePosition: false, synchronizeRotation: true, allowAntiJitter: false);
|
||
|
// }
|
||
|
// }
|
||
|
// }
|
||
|
// else
|
||
|
// {
|
||
|
// Tools.hidden = false;
|
||
|
// }
|
||
|
}
|
||
|
|
||
|
public override void OnInspectorGUI()
|
||
|
{
|
||
|
FusionEditorGUI.InjectScriptHeaderDrawer(base.serializedObject);
|
||
|
UnityEditor.Editor.DrawPropertiesExcluding(base.serializedObject, _excludedProperties);
|
||
|
IEnumerator enumerator = base.serializedObject.FindProperty("_settings").GetEnumerator();
|
||
|
while (enumerator.MoveNext())
|
||
|
{
|
||
|
if (enumerator.Current is SerializedProperty serializedProperty && serializedProperty.propertyPath.IndexOf('.') == serializedProperty.propertyPath.LastIndexOf('.'))
|
||
|
{
|
||
|
EditorGUILayout.PropertyField(serializedProperty);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
base.serializedObject.ApplyModifiedProperties();
|
||
|
}
|
||
|
}
|
||
|
}
|