Skip to content

Commit

Permalink
library
Browse files Browse the repository at this point in the history
  • Loading branch information
izayoijiichan committed Jan 15, 2020
1 parent 1f5839c commit f8d516f
Show file tree
Hide file tree
Showing 51 changed files with 2,144 additions and 0 deletions.
8 changes: 8 additions & 0 deletions MToon.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions MToon/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions MToon/Editor/EditorUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System.IO;
using System.Text.RegularExpressions;
using UnityEditor;
using UnityEngine;

namespace MToon
{
public class EditorUtils
{
private static string BasePath { get { return Path.Combine(Application.dataPath, "VRM/MToon"); } }

private static string ShaderFilePath { get { return Path.Combine(BasePath, "MToon/Resources/Shaders/MToon.shader"); } }
private static string ReadMeFilePath { get { return Path.Combine(BasePath, "README.md"); } }
private static string VersionFilePath { get { return Path.Combine(BasePath, "MToon/Scripts/UtilsVersion.cs"); } }


//[MenuItem("VRM/MToon Version Up")]
private static void VerUp(string version)
{
UpdateShaderFile(version);
UpdateReadMeFile(version);
UpdateVersionFile(version);
}

private static void UpdateShaderFile(string version)
{
var file = File.ReadAllText(ShaderFilePath);
file = Regex.Replace(
file,
"(_MToonVersion \\(\"_MToonVersion\", Float\\) = )(\\d+)",
"${1}" + version
);
File.WriteAllText(ShaderFilePath, file);
}

private static void UpdateReadMeFile(string version)
{
version = "v" + version.Substring(0, version.Length - 1) + "." + version[version.Length - 1];

var file = File.ReadAllText(ReadMeFilePath);
file = Regex.Replace(
file,
"v(\\d+)\\.(\\d+)",
version
);
File.WriteAllText(ReadMeFilePath, file);
}

private static void UpdateVersionFile(string version)
{
var file = File.ReadAllText(VersionFilePath);
file = Regex.Replace(
file,
"(public const int VersionNumber = )(\\d+)(;)",
"${1}" + version + "${3}"
);
File.WriteAllText(VersionFilePath, file);

}
}
}
3 changes: 3 additions & 0 deletions MToon/Editor/EditorUtils.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions MToon/Editor/MToon.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "MToon.Editor",
"references": [
"MToon"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false
}
7 changes: 7 additions & 0 deletions MToon/Editor/MToon.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f8d516f

Please sign in to comment.