Fix texture naming error.

Fix texture naming error.
FixedString32 -> FixedString64.
This commit is contained in:
max 2021-01-19 16:35:37 +01:00
parent a3c0ea934e
commit c3fd688619
6 changed files with 37 additions and 14 deletions

View File

@ -79,6 +79,18 @@ namespace TAO.VertexAnimation.Editor
} }
} }
private void OnValidate()
{
if (materialShader == null)
{
materialShader = Shader.Find("VA_VertexAnimationBase");
if (materialShader == null)
{
materialShader = Shader.Find("Shader Graphs/VA_VertexAnimationBase");
}
}
}
public void Bake() public void Bake()
{ {
var target = Instantiate(model); var target = Instantiate(model);

View File

@ -158,7 +158,7 @@ namespace TAO.VertexAnimation
GameObject.DestroyImmediate(inst); GameObject.DestroyImmediate(inst);
positionMap.name = string.Format("VA_N-{0}_F-{1}_MF-{2}_FPS-{3}", animationClip.name, animationInfo.frames, animationInfo.maxFrames, animationInfo.fps); positionMap.name = string.Format("VA_N-{0}_F-{1}_MF-{2}_FPS-{3}", NamingConventionUtils.ConvertToValidString(animationClip.name), animationInfo.frames, animationInfo.maxFrames, animationInfo.fps);
positionMap.filterMode = FilterMode.Point; positionMap.filterMode = FilterMode.Point;
positionMap.Apply(false, true); positionMap.Apply(false, true);

View File

@ -1,6 +1,4 @@
using System.Collections; using System.Linq;
using System.Collections.Generic;
using UnityEngine;
namespace TAO.VertexAnimation namespace TAO.VertexAnimation
{ {
@ -50,5 +48,10 @@ namespace TAO.VertexAnimation
return textureInfo; return textureInfo;
} }
public static string ConvertToValidString(this string str)
{
return string.Concat(str.Where(char.IsLetterOrDigit));
}
} }
} }

View File

@ -16,13 +16,13 @@ namespace TAO.VertexAnimation
public VA_AnimationData GetData() public VA_AnimationData GetData()
{ {
// TODO: Fix data name, FixedString32 doesn't transfer from editor? // TODO: Fix data name, FixedString32 doesn't transfer from editor?
Data.name = new FixedString32(name); Data.name = new FixedString64(name);
return Data; return Data;
} }
public FixedString32 GetName() public FixedString64 GetName()
{ {
return new FixedString32(this.name); return new FixedString64(this.name);
} }
} }
} }

View File

@ -53,12 +53,20 @@ namespace TAO.VertexAnimation
public bool TryAddMaterial(Material material) public bool TryAddMaterial(Material material)
{ {
if (!materials.Contains(material)) if (material != null)
{ {
if (material.HasProperty("_PositionMap") && material.HasProperty("_MaxFrames")) if (materials == null)
{ {
materials.Add(material); materials = new List<Material>();
return true; }
if (!materials.Contains(material))
{
if (material.HasProperty("_PositionMap") && material.HasProperty("_MaxFrames"))
{
materials.Add(material);
return true;
}
} }
} }

View File

@ -6,7 +6,7 @@ namespace TAO.VertexAnimation
[System.Serializable] [System.Serializable]
public struct VA_AnimationData public struct VA_AnimationData
{ {
public VA_AnimationData(FixedString32 a_name, int a_frames, int a_maxFrames, int a_fps, int a_positionMapIndex, int a_colorMapIndex = -1) public VA_AnimationData(FixedString64 a_name, int a_frames, int a_maxFrames, int a_fps, int a_positionMapIndex, int a_colorMapIndex = -1)
{ {
name = a_name; name = a_name;
frames = a_frames; frames = a_frames;
@ -18,7 +18,7 @@ namespace TAO.VertexAnimation
} }
// The name of the animation. // The name of the animation.
public FixedString32 name; public FixedString64 name;
// The frames in this animation. // The frames in this animation.
public int frames; public int frames;
// The maximum of frames the texture holds. // The maximum of frames the texture holds.
@ -42,7 +42,7 @@ namespace TAO.VertexAnimation
{ {
public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary"; public const string AnimationLibraryAssetStoreName = "VA_AnimationLibrary";
public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString32 animationName) public static int GetAnimation(ref VA_AnimationLibraryData animationsRef, FixedString64 animationName)
{ {
for (int i = 0; i < animationsRef.animations.Length; i++) for (int i = 0; i < animationsRef.animations.Length; i++)
{ {