You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
using System.Collections.Generic;
using UnityEngine;
using UniRx.Async;
using UniRx;
using VRM;
using System.Linq;
public static class Extensions
{
public static IEnumerable<IEnumerable> Chunks(this IEnumerable list, int size)
{
while (list.Any())
{
yield return list.Take(size);
list = list.Skip(size);
}
}
}
public class Vrmtest : MonoBehaviour
{
async void Start()
{
var path = Application.streamingAssetsPath + "/" + "Inaba-Haneru.vrm";
var www = new WWW(path);
await www;
Debug.Log(www.bytes);
var go = await VRMImporter.LoadVrmAsync(www.bytes);
go.transform.position = new Vector3(1, 1, 1);
var data = bound(divide(www.bytes));
var second = await VRMImporter.LoadVrmAsync(data);
second.transform.position = new Vector3(0, 0, 0);
}
string[] divide(byte[] data)
{
int length = data.Length / (20000);
var list =new List<string>();
foreach (var chunk in data.Chunks(20000))
{
var bytes = chunk.ToArray();
list.Add(System.Text.Encoding.Unicode.GetString(bytes));
}
return list.ToArray();
}
byte[] bound(string[] arr)
{
var list = new List<byte>();
foreach (var str in arr)
{
var encode= System.Text.Encoding.Unicode.GetBytes(str);
foreach(var bit in encode)
{
list.Add(bit);
}
}
return list.ToArray();
}
}
The text was updated successfully, but these errors were encountered:
vrm→bytes→string→bytes→gameobjectの変換をするとマテリアルが反映されないです。
サンプルコード
///////////////////////////////
using System.Collections.Generic;
using UnityEngine;
using UniRx.Async;
using UniRx;
using VRM;
using System.Linq;
public static class Extensions
{
public static IEnumerable<IEnumerable> Chunks(this IEnumerable list, int size)
{
while (list.Any())
{
yield return list.Take(size);
list = list.Skip(size);
}
}
}
public class Vrmtest : MonoBehaviour
{
}
The text was updated successfully, but these errors were encountered: