2023-01-22 16:38:23 +01:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEditor.Animations;
|
|
|
|
using UnityEditorInternal;
|
|
|
|
using AnimatorController = UnityEditor.Animations.AnimatorController;
|
|
|
|
using AnimatorControllerParameter = UnityEngine.AnimatorControllerParameter;
|
|
|
|
using AnimatorControllerParameterType = UnityEngine.AnimatorControllerParameterType;
|
|
|
|
using BlendTree = UnityEditor.Animations.BlendTree;
|
2024-08-03 22:24:42 +02:00
|
|
|
using AnimatorControllerLayer = UnityEditor.Animations.AnimatorControllerLayer;
|
2023-01-22 16:38:23 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace ABI.CCK.Scripts
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancedAvatarSettings
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
public List<CVRAdvancedSettingsEntry> settings = new();
|
|
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
public bool initialized;
|
|
|
|
|
|
|
|
// only used by autogen
|
2023-01-22 16:38:23 +01:00
|
|
|
public RuntimeAnimatorController baseController;
|
|
|
|
public RuntimeAnimatorController baseOverrideController;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
// only used *during* autogen
|
2023-01-22 16:38:23 +01:00
|
|
|
public AnimatorController animator;
|
|
|
|
public AnimatorOverrideController overrides;
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#region Helper Methods
|
|
|
|
|
|
|
|
private static readonly List<CVRAdvancesAvatarSettingBase.ParameterType> _allTypes = new()
|
|
|
|
{
|
|
|
|
CVRAdvancesAvatarSettingBase.ParameterType.Float,
|
|
|
|
CVRAdvancesAvatarSettingBase.ParameterType.Int,
|
|
|
|
CVRAdvancesAvatarSettingBase.ParameterType.Bool
|
|
|
|
};
|
|
|
|
|
|
|
|
private static readonly List<CVRAdvancesAvatarSettingBase.ParameterType> _multiValueTypes = new()
|
|
|
|
{
|
|
|
|
CVRAdvancesAvatarSettingBase.ParameterType.Float,
|
|
|
|
CVRAdvancesAvatarSettingBase.ParameterType.Int
|
|
|
|
};
|
|
|
|
|
|
|
|
private static readonly List<CVRAdvancesAvatarSettingBase.ParameterType> _onlyFloatType = new()
|
|
|
|
{
|
|
|
|
CVRAdvancesAvatarSettingBase.ParameterType.Float
|
|
|
|
};
|
|
|
|
|
|
|
|
public static List<CVRAdvancesAvatarSettingBase.ParameterType> GetSupportedTypes(
|
|
|
|
CVRAdvancedSettingsEntry.SettingsType settingType)
|
|
|
|
{
|
|
|
|
// to prevent alloc each draw, returns static list
|
|
|
|
return settingType switch
|
|
|
|
{
|
|
|
|
// Toggles can use all
|
|
|
|
CVRAdvancedSettingsEntry.SettingsType.Toggle => _allTypes,
|
|
|
|
// Dropdowns can only use float, int
|
|
|
|
CVRAdvancedSettingsEntry.SettingsType.Dropdown => _multiValueTypes,
|
|
|
|
_ => _onlyFloatType // Everything else is Float
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CVRAdvancesAvatarSettingBase.ParameterType GetDefaultType(
|
|
|
|
CVRAdvancedSettingsEntry.SettingsType settingType)
|
|
|
|
{
|
|
|
|
return settingType switch
|
|
|
|
{
|
|
|
|
// Toggles default to Bool
|
|
|
|
CVRAdvancedSettingsEntry.SettingsType.Toggle => CVRAdvancesAvatarSettingBase.ParameterType.Bool,
|
|
|
|
// Dropdowns default to Int
|
|
|
|
CVRAdvancedSettingsEntry.SettingsType.Dropdown => CVRAdvancesAvatarSettingBase.ParameterType.Int,
|
|
|
|
_ => CVRAdvancesAvatarSettingBase.ParameterType.Float // Everything else is Float
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#region Filtering Attribute Classes
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
|
|
public class UseBool : Attribute
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
|
|
public class UseInt : Attribute
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
|
|
|
public class UseFloat : Attribute
|
|
|
|
{
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancedSettingsEntry
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public bool isCollapsed;
|
|
|
|
public bool unlinkNameFromMachineName;
|
|
|
|
public bool isAutogenCollapsed = true;
|
|
|
|
#endif
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
public enum SettingsType
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
Toggle,
|
|
|
|
Dropdown,
|
|
|
|
Color,
|
2023-01-22 16:38:23 +01:00
|
|
|
Slider,
|
|
|
|
Joystick2D,
|
|
|
|
Joystick3D,
|
|
|
|
InputSingle,
|
|
|
|
InputVector2,
|
|
|
|
InputVector3
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
public SettingsType type = SettingsType.Toggle;
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
public CVRAdvancesAvatarSettingBase setting
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
case SettingsType.Color:
|
2023-01-22 16:38:23 +01:00
|
|
|
return materialColorSettings;
|
2024-08-03 22:24:42 +02:00
|
|
|
case SettingsType.Dropdown:
|
2023-01-22 16:38:23 +01:00
|
|
|
return dropDownSettings;
|
|
|
|
case SettingsType.Slider:
|
|
|
|
return sliderSettings;
|
|
|
|
case SettingsType.Joystick2D:
|
|
|
|
return joystick2DSetting;
|
|
|
|
case SettingsType.Joystick3D:
|
|
|
|
return joystick3DSetting;
|
|
|
|
case SettingsType.InputSingle:
|
|
|
|
return inputSingleSettings;
|
|
|
|
case SettingsType.InputVector2:
|
|
|
|
return inputVector2Settings;
|
|
|
|
case SettingsType.InputVector3:
|
|
|
|
return inputVector3Settings;
|
|
|
|
default:
|
|
|
|
return toggleSettings;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
case SettingsType.Color:
|
|
|
|
materialColorSettings = (CVRAdvancedAvatarSettingMaterialColor)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
2024-08-03 22:24:42 +02:00
|
|
|
case SettingsType.Dropdown:
|
|
|
|
dropDownSettings = (CVRAdvancesAvatarSettingGameObjectDropdown)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
case SettingsType.Slider:
|
2024-08-03 22:24:42 +02:00
|
|
|
sliderSettings = (CVRAdvancesAvatarSettingSlider)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
case SettingsType.Joystick2D:
|
2024-08-03 22:24:42 +02:00
|
|
|
joystick2DSetting = (CVRAdvancesAvatarSettingJoystick2D)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
case SettingsType.Joystick3D:
|
2024-08-03 22:24:42 +02:00
|
|
|
joystick3DSetting = (CVRAdvancesAvatarSettingJoystick3D)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
case SettingsType.InputSingle:
|
2024-08-03 22:24:42 +02:00
|
|
|
inputSingleSettings = (CVRAdvancesAvatarSettingInputSingle)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
case SettingsType.InputVector2:
|
2024-08-03 22:24:42 +02:00
|
|
|
inputVector2Settings = (CVRAdvancesAvatarSettingInputVector2)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
case SettingsType.InputVector3:
|
2024-08-03 22:24:42 +02:00
|
|
|
inputVector3Settings = (CVRAdvancesAvatarSettingInputVector3)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
default:
|
2024-08-03 22:24:42 +02:00
|
|
|
toggleSettings = (CVRAdvancesAvatarSettingGameObjectToggle)value;
|
2023-01-22 16:38:23 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingGameObjectToggle toggleSettings;
|
|
|
|
[SerializeField] public CVRAdvancedAvatarSettingMaterialColor materialColorSettings;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingGameObjectDropdown dropDownSettings;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingSlider sliderSettings;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingJoystick2D joystick2DSetting;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingJoystick3D joystick3DSetting;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingInputSingle inputSingleSettings;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingInputVector2 inputVector2Settings;
|
|
|
|
[SerializeField] public CVRAdvancesAvatarSettingInputVector3 inputVector3Settings;
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
public string name;
|
|
|
|
public string machineName;
|
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancesAvatarSettingBase
|
|
|
|
{
|
|
|
|
public enum ParameterType
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
Float = 1,
|
|
|
|
Int = 2,
|
|
|
|
Bool = 3
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public ParameterType usedType = ParameterType.Bool; // default SettingsType is Toggle
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public int currentEntryIndex;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public virtual void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancesAvatarSettingGameObjectToggle : CVRAdvancesAvatarSettingBase
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
public bool defaultValue;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
|
|
#region Autogen Fields & Setup
|
|
|
|
|
|
|
|
public ReorderableList reorderableList; // created & used by AdvSettings Editor
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
public bool useAnimationClip;
|
|
|
|
public AnimationClip animationClip;
|
2023-07-30 01:20:46 +02:00
|
|
|
public AnimationClip offAnimationClip;
|
2024-08-03 22:24:42 +02:00
|
|
|
public List<CVRAdvancedSettingsTargetEntryGameObject> gameObjectTargets = new();
|
|
|
|
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
|
|
|
|
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameter = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Bool,
|
|
|
|
defaultBool = defaultValue
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Float)
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorParameter = new AnimatorControllerParameter
|
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue ? 1f : 0f
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Int)
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorParameter = new AnimatorControllerParameter
|
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Int,
|
|
|
|
defaultInt = defaultValue ? 1 : 0
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameter);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip onClip = new();
|
|
|
|
AnimationClip offClip = new();
|
|
|
|
|
|
|
|
AnimationCurve animationCurveOn = new();
|
|
|
|
Keyframe keyframe = new(0f, 1);
|
2023-01-22 16:38:23 +01:00
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOn.AddKey(keyframe);
|
|
|
|
keyframe = new Keyframe(1f / 60f, 1);
|
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOn.AddKey(keyframe);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimationCurve animationCurveOff = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
keyframe = new Keyframe(0f, 0);
|
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOff.AddKey(keyframe);
|
|
|
|
keyframe = new Keyframe(1f / 60f, 0);
|
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOff.AddKey(keyframe);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
foreach (CVRAdvancedSettingsTargetEntryGameObject target in gameObjectTargets)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
if (target.gameObject == null || target.treePath == null) continue;
|
|
|
|
|
|
|
|
onClip.SetCurve(target.treePath, typeof(GameObject), "m_IsActive",
|
|
|
|
target.onState ? animationCurveOn : animationCurveOff);
|
|
|
|
|
|
|
|
offClip.SetCurve(target.treePath, typeof(GameObject), "m_IsActive",
|
|
|
|
!target.onState ? animationCurveOn : animationCurveOff);
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (useAnimationClip)
|
|
|
|
{
|
2023-01-22 16:38:23 +01:00
|
|
|
onClip = animationClip;
|
2023-07-30 01:20:46 +02:00
|
|
|
if (offAnimationClip != null)
|
|
|
|
offClip = offAnimationClip;
|
|
|
|
else
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + fileName + "_Toggle_Off.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
AssetDatabase.CreateAsset(offClip, folderPath + "/Anim_" + fileName + "_Toggle_Off.anim");
|
|
|
|
AssetDatabase.CreateAsset(onClip, folderPath + "/Anim_" + fileName + "_Toggle_On.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Bool)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState offState = animatorLayer.stateMachine.AddState(machineName + " OFF");
|
|
|
|
AnimatorState onState = animatorLayer.stateMachine.AddState(machineName + " ON");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
offState.motion = offClip;
|
|
|
|
onState.motion = onClip;
|
|
|
|
|
|
|
|
animatorLayer.stateMachine.AddAnyStateTransition(onState);
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].destinationState = onState;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].duration = 0f;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].hasExitTime = false;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].canTransitionToSelf = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0]
|
|
|
|
.AddCondition(AnimatorConditionMode.If, 0f, machineName);
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.AddAnyStateTransition(offState);
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].destinationState = offState;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].duration = 0f;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].hasExitTime = false;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].canTransitionToSelf = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1]
|
|
|
|
.AddCondition(AnimatorConditionMode.IfNot, 0f, machineName);
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Int)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState offState = animatorLayer.stateMachine.AddState(machineName + " OFF");
|
|
|
|
AnimatorState onState = animatorLayer.stateMachine.AddState(machineName + " ON");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
offState.motion = offClip;
|
|
|
|
onState.motion = onClip;
|
|
|
|
|
|
|
|
animatorLayer.stateMachine.AddAnyStateTransition(onState);
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].destinationState = onState;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].duration = 0f;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].hasExitTime = false;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0].canTransitionToSelf = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
animatorLayer.stateMachine.anyStateTransitions[0]
|
|
|
|
.AddCondition(AnimatorConditionMode.Equals, 1f, machineName);
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.AddAnyStateTransition(offState);
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].destinationState = offState;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].duration = 0f;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].hasExitTime = false;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1].canTransitionToSelf = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
animatorLayer.stateMachine.anyStateTransitions[1]
|
|
|
|
.AddCondition(AnimatorConditionMode.Equals, 0f, machineName);
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Float)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
BlendTree blendTree = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.name = machineName + " Blend Tree";
|
|
|
|
blendTree.blendParameter = machineName;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.AddChild(offClip, 0f);
|
|
|
|
blendTree.AddChild(onClip, 1f);
|
|
|
|
|
|
|
|
animatorState.motion = blendTree;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTree, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTree.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#endregion
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancesAvatarSettingGameObjectDropdown : CVRAdvancesAvatarSettingBase
|
|
|
|
{
|
|
|
|
public int defaultValue;
|
|
|
|
public List<CVRAdvancedSettingsDropDownEntry> options = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public string[] optionNames
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
get
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
var list = new string[options.Count];
|
|
|
|
for (var i = 0; i < options.Count; i++)
|
|
|
|
list[i] = options[i].name;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
return list;
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public ReorderableList reorderableList;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameter = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Int)
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorParameter = new AnimatorControllerParameter
|
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Int,
|
|
|
|
defaultInt = defaultValue
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameter);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationCurve animationCurveOn = new();
|
|
|
|
Keyframe keyframe = new(0f, 1);
|
2023-01-22 16:38:23 +01:00
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOn.AddKey(keyframe);
|
|
|
|
keyframe = new Keyframe(1f / 60f, 1);
|
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOn.AddKey(keyframe);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimationCurve animationCurveOff = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
keyframe = new Keyframe(0f, 0);
|
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOff.AddKey(keyframe);
|
|
|
|
keyframe = new Keyframe(1f / 60f, 0);
|
|
|
|
keyframe.outTangent = Mathf.Infinity;
|
|
|
|
animationCurveOff.AddKey(keyframe);
|
|
|
|
|
|
|
|
var i = 0;
|
|
|
|
AnimationClip animation;
|
2024-08-03 22:24:42 +02:00
|
|
|
var animations = new List<AnimationClip>();
|
|
|
|
foreach (CVRAdvancedSettingsDropDownEntry option in options)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
animation = new AnimationClip();
|
|
|
|
var j = 0;
|
2024-08-03 22:24:42 +02:00
|
|
|
if (option.useAnimationClip && option.animationClip != null)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
animation = option.animationClip;
|
2024-08-03 22:24:42 +02:00
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
var activeGameobjects = new List<CVRAdvancedSettingsTargetEntryGameObject>();
|
|
|
|
var inActiveGameobjects = new List<CVRAdvancedSettingsTargetEntryGameObject>();
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
foreach (CVRAdvancedSettingsDropDownEntry activeOption in options)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
foreach (CVRAdvancedSettingsTargetEntryGameObject gameObjectTarget in activeOption
|
|
|
|
.gameObjectTargets)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
if (gameObjectTarget == null || gameObjectTarget.gameObject == null ||
|
|
|
|
gameObjectTarget.treePath == null) continue;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
if (i == j && gameObjectTarget.onState)
|
|
|
|
activeGameobjects.Add(gameObjectTarget);
|
|
|
|
else
|
|
|
|
inActiveGameobjects.Add(gameObjectTarget);
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
foreach (CVRAdvancedSettingsTargetEntryGameObject gameObjectTarget in activeGameobjects)
|
2023-01-22 16:38:23 +01:00
|
|
|
animation.SetCurve(
|
2024-08-03 22:24:42 +02:00
|
|
|
gameObjectTarget.treePath,
|
|
|
|
typeof(GameObject),
|
|
|
|
"m_IsActive",
|
2023-01-22 16:38:23 +01:00
|
|
|
animationCurveOn
|
|
|
|
);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
foreach (CVRAdvancedSettingsTargetEntryGameObject gameObjectTarget in inActiveGameobjects)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
if (activeGameobjects.Find(match => match.treePath == gameObjectTarget.treePath) != null)
|
|
|
|
continue;
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animation.SetCurve(
|
2024-08-03 22:24:42 +02:00
|
|
|
gameObjectTarget.treePath,
|
|
|
|
typeof(GameObject),
|
|
|
|
"m_IsActive",
|
2023-01-22 16:38:23 +01:00
|
|
|
animationCurveOff
|
|
|
|
);
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AssetDatabase.CreateAsset(animation, folderPath + "/Anim_" + fileName + "_Dropdown_" + i + ".anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
animations.Add(animation);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
if (usedType == ParameterType.Float)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
BlendTree blendTree = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.name = machineName + " Blend Tree";
|
|
|
|
blendTree.blendParameter = machineName;
|
|
|
|
blendTree.useAutomaticThresholds = false;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
foreach (AnimationClip animationClip in animations)
|
|
|
|
{
|
|
|
|
blendTree.AddChild(animationClip, i);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
animatorState.motion = blendTree;
|
|
|
|
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTree, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTree.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (usedType == ParameterType.Int)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
foreach (AnimationClip animationClip in animations)
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState state = animatorLayer.stateMachine.AddState(machineName + " Option " + i);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
state.motion = animationClip;
|
|
|
|
|
|
|
|
animatorLayer.stateMachine.AddAnyStateTransition(state);
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[i].destinationState = state;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[i].duration = 0f;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[i].hasExitTime = false;
|
|
|
|
animatorLayer.stateMachine.anyStateTransitions[i].canTransitionToSelf = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
animatorLayer.stateMachine.anyStateTransitions[i]
|
|
|
|
.AddCondition(AnimatorConditionMode.Equals, i, machineName);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancedAvatarSettingMaterialColor : CVRAdvancesAvatarSettingBase
|
|
|
|
{
|
|
|
|
public Color defaultValue = Color.white;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public ReorderableList reorderableList;
|
|
|
|
|
|
|
|
public List<CVRAdvancedSettingsTargetEntryMaterialColor> materialColorTargets = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameterR = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-r",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.r
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterR);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterG = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-g",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.g
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterG);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterB = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-b",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.b
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterB);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
|
|
|
|
|
|
|
BlendTree blendTreeRed = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRed.name = machineName + " Blend Tree Red";
|
|
|
|
blendTreeRed.blendParameter = machineName + "-r";
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeRedMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMin.name = machineName + " Blend Tree Red Min";
|
|
|
|
blendTreeRedMin.blendParameter = machineName + "-g";
|
|
|
|
blendTreeRedMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeRedMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMax.name = machineName + " Blend Tree Red Max";
|
|
|
|
blendTreeRedMax.blendParameter = machineName + "-g";
|
|
|
|
blendTreeRedMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRed.AddChild(blendTreeRedMin, 0f);
|
|
|
|
blendTreeRed.AddChild(blendTreeRedMax, 1f);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
BlendTree blendTreeRedMinGreenMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMinGreenMin.name = machineName + " Blend Tree Red Min Green Min";
|
|
|
|
blendTreeRedMinGreenMin.blendParameter = machineName + "-b";
|
|
|
|
blendTreeRedMinGreenMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeRedMinGreenMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMinGreenMax.name = machineName + " Blend Tree Red Min Green Max";
|
|
|
|
blendTreeRedMinGreenMax.blendParameter = machineName + "-b";
|
|
|
|
blendTreeRedMinGreenMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMin.AddChild(blendTreeRedMinGreenMin, 0f);
|
|
|
|
blendTreeRedMin.AddChild(blendTreeRedMinGreenMax, 1f);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeRedMaxGreenMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMaxGreenMin.name = machineName + " Blend Tree Red MaRed Green Min";
|
|
|
|
blendTreeRedMaxGreenMin.blendParameter = machineName + "-b";
|
|
|
|
blendTreeRedMaxGreenMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeRedMaxGreenMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMaxGreenMax.name = machineName + " Blend Tree Red MaRed Green Max";
|
|
|
|
blendTreeRedMaxGreenMax.blendParameter = machineName + "-b";
|
|
|
|
blendTreeRedMaxGreenMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMax.AddChild(blendTreeRedMaxGreenMin, 0f);
|
|
|
|
blendTreeRedMax.AddChild(blendTreeRedMaxGreenMax, 1f);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimationClip clipR0G0B0 = new();
|
|
|
|
AnimationClip clipR0G0B1 = new();
|
|
|
|
AnimationClip clipR0G1B0 = new();
|
|
|
|
AnimationClip clipR0G1B1 = new();
|
|
|
|
AnimationClip clipR1G0B0 = new();
|
|
|
|
AnimationClip clipR1G0B1 = new();
|
|
|
|
AnimationClip clipR1G1B0 = new();
|
|
|
|
AnimationClip clipR1G1B1 = new();
|
|
|
|
|
|
|
|
AnimationCurve animationCurve0 = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
animationCurve0.AddKey(0, 0);
|
2024-08-03 22:24:42 +02:00
|
|
|
animationCurve0.AddKey(1f / 60, 0);
|
|
|
|
AnimationCurve animationCurve1 = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
animationCurve1.AddKey(0, 1);
|
2024-08-03 22:24:42 +02:00
|
|
|
animationCurve1.AddKey(1f / 60, 1);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
foreach (CVRAdvancedSettingsTargetEntryMaterialColor target in materialColorTargets)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
if (target.gameObject == null || target.propertyName == "" || target.treePath == null) continue;
|
|
|
|
|
|
|
|
// get property type
|
|
|
|
target.propertyType = target.propertyTypeIdentifier switch
|
|
|
|
{
|
|
|
|
"SMR" => typeof(SkinnedMeshRenderer),
|
|
|
|
"MSR" => typeof(MeshRenderer),
|
|
|
|
"PTR" => typeof(ParticleSystemRenderer),
|
|
|
|
"LNR" => typeof(LineRenderer),
|
|
|
|
"TLR" => typeof(TrailRenderer),
|
|
|
|
_ => typeof(SkinnedMeshRenderer)
|
|
|
|
};
|
|
|
|
|
|
|
|
clipR0G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve0);
|
|
|
|
clipR1G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".r",
|
|
|
|
animationCurve1);
|
|
|
|
|
|
|
|
clipR0G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve1);
|
|
|
|
clipR0G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve0);
|
|
|
|
clipR1G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve0);
|
|
|
|
clipR1G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".g",
|
|
|
|
animationCurve1);
|
|
|
|
|
|
|
|
clipR0G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve1);
|
|
|
|
clipR0G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve0);
|
|
|
|
clipR0G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve0);
|
|
|
|
clipR1G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve0);
|
|
|
|
clipR1G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".b",
|
|
|
|
animationCurve1);
|
|
|
|
|
|
|
|
clipR0G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR0G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR0G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR0G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G0B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G0B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G1B0.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
|
|
|
clipR1G1B1.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName + ".a",
|
|
|
|
animationCurve1);
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMinGreenMin.AddChild(clipR0G0B0, 0);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR0G0B0, folderPath + "/Anim_" + fileName + "_Color_R0G0B0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMinGreenMin.AddChild(clipR0G0B1, 1);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR0G0B1, folderPath + "/Anim_" + fileName + "_Color_R0G0B1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMinGreenMax.AddChild(clipR0G1B0, 0);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR0G1B0, folderPath + "/Anim_" + fileName + "_Color_R0G1B0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMinGreenMax.AddChild(clipR0G1B1, 1);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR0G1B1, folderPath + "/Anim_" + fileName + "_Color_R0G1B1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMaxGreenMin.AddChild(clipR1G0B0, 0);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR1G0B0, folderPath + "/Anim_" + fileName + "_Color_R1G0B0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMaxGreenMin.AddChild(clipR1G0B1, 1);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR1G0B1, folderPath + "/Anim_" + fileName + "_Color_R1G0B1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMaxGreenMax.AddChild(clipR1G1B0, 0);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR1G1B0, folderPath + "/Anim_" + fileName + "_Color_R1G1B0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeRedMaxGreenMax.AddChild(clipR1G1B1, 1);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipR1G1B1, folderPath + "/Anim_" + fileName + "_Color_R1G1B1.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
animatorState.motion = blendTreeRed;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRed, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRed.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRedMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRedMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRedMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRedMax.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRedMinGreenMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRedMinGreenMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRedMinGreenMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRedMinGreenMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRedMaxGreenMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRedMaxGreenMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeRedMaxGreenMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeRedMaxGreenMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancesAvatarSettingSlider : CVRAdvancesAvatarSettingBase
|
|
|
|
{
|
|
|
|
public float defaultValue;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public List<CVRAdvancedSettingsTargetEntryMaterialProperty> materialPropertyTargets = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
private CVRAdvancedSettingsTargetEntryMaterialProperty entity;
|
|
|
|
#if UNITY_EDITOR
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public ReorderableList reorderableList;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public bool useAnimationClip;
|
|
|
|
public AnimationClip minAnimationClip;
|
|
|
|
public AnimationClip maxAnimationClip;
|
|
|
|
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
|
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameter = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue
|
|
|
|
};
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
controller.AddParameter(animatorParameter);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
BlendTree blendTree = new();
|
|
|
|
blendTree.name = machineName + " Blend Tree";
|
|
|
|
blendTree.blendParameter = machineName;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip minClip = new();
|
|
|
|
AnimationClip maxClip = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
foreach (CVRAdvancedSettingsTargetEntryMaterialProperty target in materialPropertyTargets)
|
|
|
|
{
|
|
|
|
if (target.gameObject == null || target.propertyName == "" || target.treePath == null) continue;
|
|
|
|
|
|
|
|
AnimationCurve animationCurve0 = new();
|
|
|
|
animationCurve0.AddKey(0, target.minValue);
|
|
|
|
animationCurve0.AddKey(1f / 60, target.minValue);
|
|
|
|
AnimationCurve animationCurve1 = new();
|
|
|
|
animationCurve1.AddKey(0, target.maxValue);
|
|
|
|
animationCurve1.AddKey(1f / 60, target.maxValue);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
target.propertyType = target.propertyTypeIdentifier switch
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
"SMR" => typeof(SkinnedMeshRenderer),
|
|
|
|
"MSR" => typeof(MeshRenderer),
|
|
|
|
"PTR" => typeof(ParticleSystemRenderer),
|
|
|
|
"LNR" => typeof(LineRenderer),
|
|
|
|
"TLR" => typeof(TrailRenderer),
|
|
|
|
_ => typeof(SkinnedMeshRenderer)
|
|
|
|
};
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
minClip.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName,
|
|
|
|
animationCurve0);
|
|
|
|
maxClip.SetCurve(target.treePath, target.propertyType, "material." + target.propertyName,
|
|
|
|
animationCurve1);
|
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
if (useAnimationClip)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
minClip = minAnimationClip;
|
|
|
|
maxClip = maxAnimationClip;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
AssetDatabase.CreateAsset(minClip, folderPath + "/Anim_" + fileName + "_Slider_Min.anim");
|
|
|
|
AssetDatabase.CreateAsset(maxClip, folderPath + "/Anim_" + fileName + "_Slider_Max.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.AddChild(minClip, 0f);
|
|
|
|
blendTree.AddChild(maxClip, 1f);
|
|
|
|
|
|
|
|
animatorState.motion = blendTree;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTree, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTree.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancesAvatarSettingJoystick2D : CVRAdvancesAvatarSettingBase
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
public Vector2 defaultValue = Vector2.zero;
|
2024-08-03 22:24:42 +02:00
|
|
|
public Vector2 rangeMin = new(0, 0);
|
|
|
|
public Vector2 rangeMax = new(1, 1);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameterX = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-x",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.x
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterX);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterY = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-y",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.y
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterY);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
|
|
|
|
|
|
|
BlendTree blendTree = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.name = machineName + " Blend Tree";
|
|
|
|
blendTree.blendParameter = machineName + "-x";
|
|
|
|
blendTree.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.name = machineName + " Blend Tree X Min";
|
|
|
|
blendTreeXMin.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.name = machineName + " Blend Tree X Max";
|
|
|
|
blendTreeXMax.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.AddChild(blendTreeXMin, rangeMin.x);
|
|
|
|
blendTree.AddChild(blendTreeXMax, rangeMax.x);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip X0Y0Clip = new();
|
|
|
|
AnimationClip X0Y1Clip = new();
|
|
|
|
AnimationClip X1Y0Clip = new();
|
|
|
|
AnimationClip X1Y1Clip = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
blendTreeXMin.AddChild(X0Y0Clip, rangeMin.y);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X0Y0Clip, folderPath + "/Anim_" + fileName + "_Joystick2D_X0Y0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.AddChild(X0Y1Clip, rangeMax.y);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X0Y1Clip, folderPath + "/Anim_" + fileName + "_Joystick2D_X0Y1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.AddChild(X1Y0Clip, rangeMin.y);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X1Y0Clip, folderPath + "/Anim_" + fileName + "_Joystick2D_X1Y0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.AddChild(X1Y1Clip, rangeMax.y);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X1Y1Clip, folderPath + "/Anim_" + fileName + "_Joystick2D_X1Y1.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
animatorState.motion = blendTree;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTree, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTree.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancesAvatarSettingJoystick3D : CVRAdvancesAvatarSettingBase
|
|
|
|
{
|
|
|
|
public Vector3 defaultValue = Vector3.zero;
|
2024-08-03 22:24:42 +02:00
|
|
|
public Vector3 rangeMin = new(0, 0, 0);
|
|
|
|
public Vector3 rangeMax = new(1, 1, 1);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameterX = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-x",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.x
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterX);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterY = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-y",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.y
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterY);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterZ = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-z",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.z
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterZ);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
|
|
|
|
|
|
|
BlendTree blendTreeX = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeX.name = machineName + " Blend Tree x";
|
|
|
|
blendTreeX.blendParameter = machineName + "-x";
|
|
|
|
blendTreeX.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.name = machineName + " Blend Tree X Min";
|
|
|
|
blendTreeXMin.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.name = machineName + " Blend Tree X Max";
|
|
|
|
blendTreeXMax.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeX.AddChild(blendTreeXMin, rangeMin.x);
|
|
|
|
blendTreeX.AddChild(blendTreeXMax, rangeMax.x);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
BlendTree blendTreeXMinYMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMin.name = machineName + " Blend Tree X Min Y Min";
|
|
|
|
blendTreeXMinYMin.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMinYMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMinYMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMax.name = machineName + " Blend Tree X Min Y Max";
|
|
|
|
blendTreeXMinYMax.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMinYMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.AddChild(blendTreeXMinYMin, rangeMin.y);
|
|
|
|
blendTreeXMin.AddChild(blendTreeXMinYMax, rangeMax.y);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMaxYMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMin.name = machineName + " Blend Tree X Max Y Min";
|
|
|
|
blendTreeXMaxYMin.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMaxYMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMaxYMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMax.name = machineName + " Blend Tree X Max Y Max";
|
|
|
|
blendTreeXMaxYMax.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMaxYMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.AddChild(blendTreeXMaxYMin, rangeMin.y);
|
|
|
|
blendTreeXMax.AddChild(blendTreeXMaxYMax, rangeMax.y);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip clipX0Y0Z0 = new();
|
|
|
|
AnimationClip clipX0Y0Z1 = new();
|
|
|
|
AnimationClip clipX0Y1Z0 = new();
|
|
|
|
AnimationClip clipX0Y1Z1 = new();
|
|
|
|
AnimationClip clipX1Y0Z0 = new();
|
|
|
|
AnimationClip clipX1Y0Z1 = new();
|
|
|
|
AnimationClip clipX1Y1Z0 = new();
|
|
|
|
AnimationClip clipX1Y1Z1 = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
blendTreeXMinYMin.AddChild(clipX0Y0Z0, 0f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y0Z0, folderPath + "/Anim_" + fileName + "_Joystick3D_X0Y0Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMin.AddChild(clipX0Y0Z1, 1f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y0Z1, folderPath + "/Anim_" + fileName + "_Joystick3D_X0Y0Z1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMax.AddChild(clipX0Y1Z0, 0f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y1Z0, folderPath + "/Anim_" + fileName + "_Joystick3D_X0Y1Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMax.AddChild(clipX0Y1Z1, 1f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y1Z1, folderPath + "/Anim_" + fileName + "_Joystick3D_X0Y1Z1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMin.AddChild(clipX1Y0Z0, 0f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y0Z0, folderPath + "/Anim_" + fileName + "_Joystick3D_X1Y0Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMin.AddChild(clipX1Y0Z1, 1f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y0Z1, folderPath + "/Anim_" + fileName + "_Joystick3D_X1Y0Z1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMax.AddChild(clipX1Y1Z0, 0f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y1Z0, folderPath + "/Anim_" + fileName + "_Joystick3D_X1Y1Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMax.AddChild(clipX1Y1Z1, 1f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y1Z1, folderPath + "/Anim_" + fileName + "_Joystick3D_X1Y1Z1.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
animatorState.motion = blendTreeX;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeX, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeX.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMax.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMinYMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMinYMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMinYMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMinYMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMaxYMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMaxYMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMaxYMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMaxYMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancesAvatarSettingInputSingle : CVRAdvancesAvatarSettingBase
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
public float defaultValue;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameter = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameter);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
|
|
|
|
|
|
|
BlendTree blendTree = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.name = machineName + " Blend Tree";
|
|
|
|
blendTree.blendParameter = machineName;
|
|
|
|
blendTree.useAutomaticThresholds = false;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip minClip = new();
|
|
|
|
AnimationClip maxClip = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
blendTree.AddChild(minClip, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(minClip, folderPath + "/Anim_" + fileName + "_InputSingle_Min.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.AddChild(maxClip, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(maxClip, folderPath + "/Anim_" + fileName + "_InputSingle_Max.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
animatorState.motion = blendTree;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTree, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTree.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancesAvatarSettingInputVector2 : CVRAdvancesAvatarSettingBase
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
public Vector2 defaultValue = Vector2.zero;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameterX = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-x",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.x
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterX);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterY = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-y",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.y
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterY);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
|
|
|
|
|
|
|
BlendTree blendTree = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.name = machineName + " Blend Tree";
|
|
|
|
blendTree.blendParameter = machineName + "-x";
|
|
|
|
blendTree.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.name = machineName + " Blend Tree X Min";
|
|
|
|
blendTreeXMin.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.name = machineName + " Blend Tree X Max";
|
|
|
|
blendTreeXMax.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTree.AddChild(blendTreeXMin, -9999f);
|
|
|
|
blendTree.AddChild(blendTreeXMax, 9999f);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip X0Y0Clip = new();
|
|
|
|
AnimationClip X0Y1Clip = new();
|
|
|
|
AnimationClip X1Y0Clip = new();
|
|
|
|
AnimationClip X1Y1Clip = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
blendTreeXMin.AddChild(X0Y0Clip, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X0Y0Clip, folderPath + "/Anim_" + fileName + "_InputVector2_X0Y0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.AddChild(X0Y1Clip, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X0Y1Clip, folderPath + "/Anim_" + fileName + "_InputVector2_X0Y1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.AddChild(X1Y0Clip, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X1Y0Clip, folderPath + "/Anim_" + fileName + "_InputVector2_X1Y0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.AddChild(X1Y1Clip, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(X1Y1Clip, folderPath + "/Anim_" + fileName + "_InputVector2_X1Y1.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
animatorState.motion = blendTree;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTree, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTree.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancesAvatarSettingInputVector3 : CVRAdvancesAvatarSettingBase
|
|
|
|
{
|
|
|
|
public Vector3 defaultValue = Vector3.zero;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public override void SetupAnimator(ref AnimatorController controller, string machineName, string folderPath,
|
|
|
|
string fileName)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerLayer animatorLayer = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName,
|
|
|
|
defaultWeight = 1f,
|
|
|
|
stateMachine = new AnimatorStateMachine()
|
|
|
|
};
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
animatorLayer.stateMachine.name = machineName;
|
|
|
|
AssetDatabase.AddObjectToAsset(animatorLayer.stateMachine, AssetDatabase.GetAssetPath(controller));
|
|
|
|
animatorLayer.stateMachine.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
controller.AddLayer(animatorLayer);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimatorControllerParameter animatorParameterX = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-x",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.x
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterX);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterY = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-y",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.y
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterY);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorControllerParameter animatorParameterZ = new()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
name = machineName + "-z",
|
|
|
|
type = AnimatorControllerParameterType.Float,
|
|
|
|
defaultFloat = defaultValue.z
|
|
|
|
};
|
|
|
|
|
|
|
|
controller.AddParameter(animatorParameterZ);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
AnimatorState animatorState = animatorLayer.stateMachine.AddState(machineName + " Blend Tree");
|
|
|
|
|
|
|
|
BlendTree blendTreeX = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeX.name = machineName + " Blend Tree x";
|
|
|
|
blendTreeX.blendParameter = machineName + "-x";
|
|
|
|
blendTreeX.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.name = machineName + " Blend Tree X Min";
|
|
|
|
blendTreeXMin.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.name = machineName + " Blend Tree X Max";
|
|
|
|
blendTreeXMax.blendParameter = machineName + "-y";
|
|
|
|
blendTreeXMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeX.AddChild(blendTreeXMin, -9999f);
|
|
|
|
blendTreeX.AddChild(blendTreeXMax, 9999f);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
BlendTree blendTreeXMinYMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMin.name = machineName + " Blend Tree X Min Y Min";
|
|
|
|
blendTreeXMinYMin.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMinYMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMinYMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMax.name = machineName + " Blend Tree X Min Y Max";
|
|
|
|
blendTreeXMinYMax.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMinYMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMin.AddChild(blendTreeXMinYMin, -9999f);
|
|
|
|
blendTreeXMin.AddChild(blendTreeXMinYMax, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMaxYMin = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMin.name = machineName + " Blend Tree X Max Y Min";
|
|
|
|
blendTreeXMaxYMin.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMaxYMin.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
BlendTree blendTreeXMaxYMax = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMax.name = machineName + " Blend Tree X Max Y Max";
|
|
|
|
blendTreeXMaxYMax.blendParameter = machineName + "-z";
|
|
|
|
blendTreeXMaxYMax.useAutomaticThresholds = false;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMax.AddChild(blendTreeXMaxYMin, -9999f);
|
|
|
|
blendTreeXMax.AddChild(blendTreeXMaxYMax, 9999f);
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
AnimationClip clipX0Y0Z0 = new();
|
|
|
|
AnimationClip clipX0Y0Z1 = new();
|
|
|
|
AnimationClip clipX0Y1Z0 = new();
|
|
|
|
AnimationClip clipX0Y1Z1 = new();
|
|
|
|
AnimationClip clipX1Y0Z0 = new();
|
|
|
|
AnimationClip clipX1Y0Z1 = new();
|
|
|
|
AnimationClip clipX1Y1Z0 = new();
|
|
|
|
AnimationClip clipX1Y1Z1 = new();
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
blendTreeXMinYMin.AddChild(clipX0Y0Z0, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y0Z0, folderPath + "/Anim_" + fileName + "_InputVector3_X0Y0Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMin.AddChild(clipX0Y0Z1, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y0Z1, folderPath + "/Anim_" + fileName + "_InputVector3_X0Y0Z1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMax.AddChild(clipX0Y1Z0, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y1Z0, folderPath + "/Anim_" + fileName + "_InputVector3_X0Y1Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMinYMax.AddChild(clipX0Y1Z1, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX0Y1Z1, folderPath + "/Anim_" + fileName + "_InputVector3_X0Y1Z1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMin.AddChild(clipX1Y0Z0, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y0Z0, folderPath + "/Anim_" + fileName + "_InputVector3_X1Y0Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMin.AddChild(clipX1Y0Z1, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y0Z1, folderPath + "/Anim_" + fileName + "_InputVector3_X1Y0Z1.anim");
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMax.AddChild(clipX1Y1Z0, -9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y1Z0, folderPath + "/Anim_" + fileName + "_InputVector3_X1Y1Z0.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
blendTreeXMaxYMax.AddChild(clipX1Y1Z1, 9999f);
|
2024-08-03 22:24:42 +02:00
|
|
|
AssetDatabase.CreateAsset(clipX1Y1Z1, folderPath + "/Anim_" + fileName + "_InputVector3_X1Y1Z1.anim");
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
animatorState.motion = blendTreeX;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeX, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeX.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMax.hideFlags = HideFlags.HideInHierarchy;
|
2024-08-03 22:24:42 +02:00
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMinYMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMinYMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMinYMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMinYMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMaxYMin, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMaxYMin.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
AssetDatabase.AddObjectToAsset(blendTreeXMaxYMax, AssetDatabase.GetAssetPath(controller));
|
|
|
|
blendTreeXMaxYMax.hideFlags = HideFlags.HideInHierarchy;
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancedSettingsTargetEntryGameObject
|
|
|
|
{
|
2023-01-22 16:38:23 +01:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public string treePath;
|
|
|
|
public bool onState = true;
|
2024-08-03 22:24:42 +02:00
|
|
|
public GameObject gameObject;
|
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
[Serializable]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CVRAdvancedSettingsDropDownEntry
|
|
|
|
{
|
|
|
|
public string name;
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public ReorderableList reorderableList;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public bool isAutogenCollapsed = true;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public bool useAnimationClip;
|
|
|
|
public AnimationClip animationClip;
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
public List<CVRAdvancedSettingsTargetEntryGameObject> gameObjectTargets = new();
|
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancedSettingsTargetEntryMaterialColor
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
public GameObject gameObject;
|
|
|
|
public string treePath;
|
|
|
|
public Type propertyType;
|
|
|
|
public string propertyTypeIdentifier;
|
|
|
|
public string propertyName;
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
[Serializable]
|
|
|
|
public class CVRAdvancedSettingsTargetEntryMaterialProperty
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
public float minValue;
|
|
|
|
public float maxValue;
|
|
|
|
|
2023-01-22 16:38:23 +01:00
|
|
|
#if UNITY_EDITOR
|
|
|
|
public GameObject gameObject;
|
|
|
|
public string treePath;
|
|
|
|
public Type propertyType;
|
|
|
|
public string propertyTypeIdentifier;
|
|
|
|
public string propertyName;
|
2024-08-03 22:24:42 +02:00
|
|
|
#endif
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
}
|