-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
Packages/uGUI-Skinner/Editor/SkinPartsInspector/AnimationSampleInspector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
namespace Pspkurara.UI.Skinner | ||
{ | ||
|
||
[SkinPartsInspector(typeof(AnimationSample))] | ||
public sealed class AnimationSampleInspector : ISkinPartsInspector | ||
{ | ||
public void CleanupFields(EditorSkinPartsPropertry property) | ||
{ | ||
SkinnerEditorUtility.CleanArray(property.objectReferenceValues, AnimationSample.ObjectLength); | ||
SkinnerEditorUtility.CleanObject<GameObject>(property.objectReferenceValues, AnimationSample.GameObjectIndex); | ||
SkinnerEditorUtility.CleanObject<AnimationClip>(property.objectReferenceValues, AnimationSample.AnimationClipIndex); | ||
SkinnerEditorUtility.CleanArray(property.boolValues); | ||
SkinnerEditorUtility.CleanArray(property.colorValues); | ||
SkinnerEditorUtility.CleanArray(property.floatValues, AnimationSample.FloatLength); | ||
SkinnerEditorUtility.CleanArray(property.intValues); | ||
SkinnerEditorUtility.CleanArray(property.vector4Values); | ||
} | ||
|
||
public void DrawInspector(EditorSkinPartsPropertry property) | ||
{ | ||
SkinnerEditorUtility.ResetArray(property.objectReferenceValues, AnimationSample.ObjectLength); | ||
SkinnerEditorUtility.ResetArray(property.floatValues, AnimationSample.FloatLength); | ||
var gameObjectProperty = property.objectReferenceValues.GetArrayElementAtIndex(AnimationSample.GameObjectIndex); | ||
var animationClipProperty = property.objectReferenceValues.GetArrayElementAtIndex(AnimationSample.AnimationClipIndex); | ||
var timeProperty = property.floatValues.GetArrayElementAtIndex(AnimationSample.TimeIndex); | ||
gameObjectProperty.objectReferenceValue = EditorGUILayout.ObjectField(SkinContent.RootGameObject, gameObjectProperty.objectReferenceValue, typeof(GameObject), true); | ||
animationClipProperty.objectReferenceValue = EditorGUILayout.ObjectField(SkinContent.AnimationClip, animationClipProperty.objectReferenceValue, typeof(AnimationClip), false); | ||
if (!animationClipProperty.hasMultipleDifferentValues && animationClipProperty.objectReferenceValue is AnimationClip) | ||
{ | ||
var clip = animationClipProperty.objectReferenceValue as AnimationClip; | ||
EditorGUILayout.Slider(timeProperty, 0, clip.length, SkinContent.SampleTime); | ||
} | ||
else | ||
{ | ||
bool showMixedValue = EditorGUI.showMixedValue; | ||
if (timeProperty.hasMultipleDifferentValues) | ||
{ | ||
EditorGUI.showMixedValue = true; | ||
} | ||
timeProperty.floatValue = EditorGUILayout.FloatField(SkinContent.SampleTime, timeProperty.floatValue); | ||
EditorGUI.showMixedValue = showMixedValue; | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
Packages/uGUI-Skinner/Editor/SkinPartsInspector/AnimationSampleInspector.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
Packages/uGUI-Skinner/Runtime/SkinParts/AnimationSample.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using UnityEngine; | ||
|
||
namespace Pspkurara.UI.Skinner | ||
{ | ||
|
||
[SkinParts(SkinPartsType.AnimationSample, typeof(AnimationSample), typeof(Logic))] | ||
public static class AnimationSample | ||
{ | ||
|
||
public const int GameObjectIndex = 0; | ||
public const int AnimationClipIndex = 1; | ||
public const int TimeIndex = 0; | ||
public const int ObjectLength = AnimationClipIndex + 1; | ||
public const int FloatLength = TimeIndex + 1; | ||
|
||
/// <summary> | ||
/// 適応ロジック | ||
/// </summary> | ||
internal sealed class Logic : ISkinLogic | ||
{ | ||
|
||
private GameObject rootGameObject = null; | ||
private AnimationClip animationClip = null; | ||
private float activeTime; | ||
|
||
/// <summary> | ||
/// 値をオブジェクトに反映させる | ||
/// </summary> | ||
/// <param name="property">プロパティ</param> | ||
public void SetValues(SkinPartsPropertry property) | ||
{ | ||
//値がないなら何もしない | ||
if (property.objectReferenceValues.Count < ObjectLength) return; | ||
if (!rootGameObject) | ||
{ | ||
rootGameObject = property.objectReferenceValues[GameObjectIndex] as GameObject; | ||
//空か型違いのため処理終了 | ||
if (!rootGameObject) return; | ||
} | ||
if (!animationClip) | ||
{ | ||
animationClip = property.objectReferenceValues[AnimationClipIndex] as AnimationClip; | ||
//空か型違いのため処理終了 | ||
if (!animationClip) return; | ||
} | ||
//値がないなら何もしない | ||
if (property.floatValues.Count < FloatLength) return; | ||
activeTime = property.floatValues[TimeIndex]; | ||
animationClip.SampleAnimation(rootGameObject, activeTime); | ||
} | ||
|
||
} | ||
|
||
/// <summary> | ||
/// 対象のスキンパーツを生成 | ||
/// </summary> | ||
/// <param name="rootGameObject">ルートとなるGameObject</param> | ||
/// <param name="animationClip">アニメーションクリップ</param> | ||
/// <param name="time">クリップをサンプルする時間</param> | ||
/// <returns>生成したスキンパーツ</returns> | ||
public static SkinParts CreateSkinParts(GameObject rootGameObject, AnimationClip animationClip, float time) | ||
{ | ||
var parts = new SkinParts(); | ||
SkinnerUtility.ResetObjectReference(parts.property.objectReferenceValues, ObjectLength); | ||
SkinnerUtility.ResetFloat(parts.property.floatValues, FloatLength); | ||
parts.property.objectReferenceValues[GameObjectIndex] = rootGameObject; | ||
parts.property.objectReferenceValues[AnimationClipIndex] = animationClip; | ||
parts.property.floatValues[TimeIndex] = time; | ||
return parts; | ||
} | ||
|
||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
Packages/uGUI-Skinner/Runtime/SkinParts/AnimationSample.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ public enum SkinPartsType | |
|
||
TransformRotation = 12, | ||
TransformScale = 13, | ||
|
||
AnimationSample = 20, | ||
} | ||
|
||
} |