本项目演示如何创建自己的顶点动画着色器。场景不使用任何纹理或动画资源,所有内容都使用Shader Graph进行着色和动画处理。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

127 行
3.6 KiB

using System;
using System.Text.RegularExpressions;
using UnityEngine;
namespace UnityEditor.Recorder
{
[Serializable]
class OutputPath
{
public enum Root
{
Project,
AssetsFolder,
StreamingAssets,
PersistentData,
TemporaryCache,
Absolute
}
[SerializeField] Root m_Root;
[SerializeField] string m_Leaf;
[SerializeField] bool m_ForceAssetFolder;
public Root root
{
get { return m_Root; }
set { m_Root = value; }
}
public string leaf
{
get { return m_Leaf; }
set { m_Leaf = value; }
}
public bool forceAssetsFolder
{
get { return m_ForceAssetFolder;}
set
{
m_ForceAssetFolder = value;
if (m_ForceAssetFolder)
m_Root = Root.AssetsFolder;
}
}
public static OutputPath FromPath(string path)
{
var result = new OutputPath();
if (path.Contains(Application.streamingAssetsPath))
{
result.m_Root = Root.StreamingAssets;
result.m_Leaf = path.Replace(Application.streamingAssetsPath, string.Empty);
}
else if (path.Contains(Application.dataPath))
{
result.m_Root = Root.AssetsFolder;
result.m_Leaf = path.Replace(Application.dataPath, string.Empty);
}
else if (path.Contains(Application.persistentDataPath))
{
result.m_Root = Root.PersistentData;
result.m_Leaf = path.Replace(Application.persistentDataPath, string.Empty);
}
else if (path.Contains(Application.temporaryCachePath))
{
result.m_Root = Root.TemporaryCache;
result.m_Leaf = path.Replace(Application.temporaryCachePath, string.Empty);
}
else if (path.Contains(ProjectPath()))
{
result.m_Root = Root.Project;
result.m_Leaf = path.Replace(ProjectPath(), string.Empty);
}
else
{
result.m_Root = Root.Absolute;
result.m_Leaf = path;
}
return result;
}
public static string GetFullPath(Root root, string leaf)
{
var ret = string.Empty;
switch (root)
{
case Root.PersistentData:
ret = Application.persistentDataPath;
break;
case Root.StreamingAssets:
ret = Application.streamingAssetsPath;
break;
case Root.TemporaryCache:
ret = Application.temporaryCachePath;
break;
case Root.AssetsFolder:
ret = Application.dataPath;
break;
case Root.Project:
ret = ProjectPath();
break;
}
if (root != Root.Absolute && !leaf.StartsWith("/"))
{
ret += "/";
}
ret += leaf;
return ret;
}
public string GetFullPath()
{
return GetFullPath(m_Root, m_Leaf);
}
static string ProjectPath()
{
return Regex.Replace(Application.dataPath, "/Assets$", string.Empty);
}
}
}