キッシュちゃんパンツパッチをUnityエディタ上から利用できるようにするエディタ拡張です
Unityエディタ上からキッシュちゃんパンツパッチに関する以下の機能が利用できるようになります
- パンツ変換元テクスチャデータの一括取得
- パンツ変換元テクスチャから、キッシュちゃんパンツパッチに対応したアバターへのパンツテクスチャ(透過PNG)の作成
こちらのwikiに掲載しています
- Unity 2017.4.28f1
キッシュちゃんパンツパッチUnityEditor
License: MIT License
キッシュちゃんパンツパッチをUnityエディタ上から利用できるようにするエディタ拡張です
Unityエディタ上からキッシュちゃんパンツパッチに関する以下の機能が利用できるようになります
こちらのwikiに掲載しています
変換後のパンツテクスチャデータとアバターのテクスチャデータを合成する機能の実装
テクスチャを重ね合わせる処理が実行段階でテクスチャ保存時にエラーを吐く
Unsupported texture format - Texture2D::EncodeTo functions do not support compressed texture formats.
UnityEngine.ImageConversion:EncodeToPNG(Texture2D)
TextureCombinator:SaveTexture(String, Texture2D) (at Assets/AliceLaboratory/Test/Editor/TextureCombinator.cs:93)
TextureCombinator:OnGUI() (at Assets/AliceLaboratory/Test/Editor/TextureCombinator.cs:83)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
NullReferenceException: Object reference not set to an instance of an object
System.IO.File.WriteAllBytes (System.String path, System.Byte[] bytes) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.IO/File.cs:595)
TextureCombinator.SaveTexture (System.String filePath, UnityEngine.Texture2D texture) (at Assets/AliceLaboratory/Test/Editor/TextureCombinator.cs:94)
TextureCombinator.OnGUI () (at Assets/AliceLaboratory/Test/Editor/TextureCombinator.cs:83)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:295)
UnityEditor.HostView.Invoke (System.String methodName) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:288)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at /Users/builduser/buildslave/unity/build/Editor/Mono/HostView.cs:255)
/// <summary>
/// テクスチャの重ね合わせ処理
/// </summary>
public static Texture2D Overlap(Texture2D overTex, Texture2D baseTex) {
var output = new Texture2D(baseTex.width, baseTex.height);
var dest = output.GetPixels();
var renderTexture = RenderTexture.GetTemporary(baseTex.width, baseTex.height);
Graphics.Blit(baseTex, renderTexture);
dest = GetPixelsFromRT(renderTexture);
Graphics.Blit(overTex, renderTexture);
var pixels = GetPixelsFromRT(renderTexture);
for (int i = 0; i < pixels.Length; i++) {
// RTのアルファ値が1ならば上書き
if(pixels[i].a == 1) {
dest[i] = pixels[i];
}
}
RenderTexture.ReleaseTemporary(renderTexture);
output.SetPixels(dest);
output.Apply();
return baseTex;
}
/// <summary>
/// RenderTextureからピクセル情報を取得する
/// </summary>
private static Color[] GetPixelsFromRT(RenderTexture target) {
var preRT = RenderTexture.active;
RenderTexture.active = target;
// ReadPixels()でレンダーターゲットからテクスチャ情報を生成する
var texture = new Texture2D(target.width, target.height);
texture.ReadPixels(new Rect(0, 0, target.width, target.height), 0, 0);
texture.Apply();
RenderTexture.active = preRT;
return texture.GetPixels();
}
var output = Utilities.Overlap(overTex:_textures[0], baseTex:_textures[1]);
// 出来たテクスチャを保存する
var filePath = EditorUtility.SaveFilePanel("Save Texture", "Assets", "name", "png");
if (!string.IsNullOrEmpty(filePath)) {
SaveTexture(filePath, output);
}
/// <summary>
/// テクスチャを保存する
/// </summary>
private void SaveTexture(string filePath, Texture2D texture)
{
var bytes = texture.EncodeToPNG();
System.IO.File.WriteAllBytes(filePath, bytes);
AssetDatabase.Refresh();
}
タイトルの通り
ユーザーからの問い合わせで発覚
issue type : [bug]
一括ダウンロードボタン投下 -> エディタが操作不可の状態
コルーチン周りが原因の可能性大のため、その辺調査
PantiePatchEditorDLWindow
クラスに追加実装(モデルデータダウンロードボタンを追加)
Editor/PantiePatch/パンツデータ一括ダウンロード
を適切な名前に変更
ボタンの、 パンツ一括ダウンロード
の文言も パンツデータダウンロード
に変更する
#35 で例外処理を行っているが、必要ない感ある
その場合どうするか考える
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.