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()
{
var target = Instantiate(model);

View File

@ -158,7 +158,7 @@ namespace TAO.VertexAnimation
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.Apply(false, true);

View File

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
namespace TAO.VertexAnimation
{
@ -50,5 +48,10 @@ namespace TAO.VertexAnimation
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()
{
// TODO: Fix data name, FixedString32 doesn't transfer from editor?
Data.name = new FixedString32(name);
Data.name = new FixedString64(name);
return Data;
}
public FixedString32 GetName()
public FixedString64 GetName()
{
return new FixedString32(this.name);
return new FixedString64(this.name);
}
}
}

View File

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

View File

@ -6,7 +6,7 @@ namespace TAO.VertexAnimation
[System.Serializable]
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;
frames = a_frames;
@ -18,7 +18,7 @@ namespace TAO.VertexAnimation
}
// The name of the animation.
public FixedString32 name;
public FixedString64 name;
// The frames in this animation.
public int frames;
// The maximum of frames the texture holds.
@ -42,7 +42,7 @@ namespace TAO.VertexAnimation
{
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++)
{