Added scripts stub

This commit is contained in:
raccoon
2025-08-25 14:56:30 +05:00
parent 7014f3cfb0
commit a04f2ef173
7 changed files with 125 additions and 0 deletions

8
Assets/hwm.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 15e7e8d532e5be04d8e0b6c5b471c696
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/hwm/Editor.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 05a6291265cab1c4bb434e058ec404fb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,21 @@
using UnityEditor;
using UnityEngine;
namespace RiggingTools.FacialAnimation
{
[CustomEditor(typeof(HWMSetup))]
public class HWMSetupEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
var script = (HWMSetup)target;
if (GUILayout.Button("Generate Anim Controller"))
{
script.GenerateAnimationController();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 909adcc30362c8d44a3fef10070fe4ad
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
Assets/hwm/Scripts.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2f658d84ba6af6849bf405c7218a9214
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Animations;
#endif
namespace RiggingTools.FacialAnimation
{
[RequireComponent(typeof(SkinnedMeshRenderer))]
public class HWMSetup : MonoBehaviour
{
[Header("Animation Settings")]
public float moveDistance = 1f;
public float duration = 2f;
#if UNITY_EDITOR
public void GenerateAnimationController()
{
var skinnedMesh = GetComponent<SkinnedMeshRenderer>();
if (skinnedMesh == null)
{
Debug.LogWarning($"Skinned Mesh Renderer not found on {gameObject.name}");
return;
}
string objName = gameObject.name;
var clip = new AnimationClip();
clip.name = objName + "_MoveUpDown";
Keyframe[] keys = {
new Keyframe(0, 0),
new Keyframe(duration / 2f, moveDistance),
new Keyframe(duration, 0)
};
var curve = new AnimationCurve(keys);
clip.SetCurve("", typeof(Transform), "localPosition.y", curve);
// Make loop
var clipSettings = AnimationUtility.GetAnimationClipSettings(clip);
clipSettings.loopTime = true;
AnimationUtility.SetAnimationClipSettings(clip, clipSettings);
AssetDatabase.CreateAsset(clip, $"Assets/{objName}_MoveUpDown.anim");
var controller = AnimatorController.CreateAnimatorControllerAtPath($"Assets/{objName}_Controller.controller");
var state = controller.layers[0].stateMachine.AddState("MoveUpDown");
state.motion = clip;
controller.layers[0].stateMachine.defaultState = state;
AssetDatabase.SaveAssets();
Debug.Log($"Generated animator setup for {objName}");
}
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9baa4cf3adb15d041a7f046e68b4fe53
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: