-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathChangeVRMCloth.cs
35 lines (28 loc) · 1.07 KB
/
ChangeVRMCloth.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
public class ChangeVRMCloth : MonoBehaviour
{
public string TextureName;
void ChangeCloth()
{
GameObject test = GameObject.FindGameObjectWithTag("VRM_Body");
Material[] mat = test.GetComponent<SkinnedMeshRenderer>().materials;
//ファイル読み込み
var path = Application.streamingAssetsPath + "/" + TextureName + ".png";
byte[] bytes = File.ReadAllBytes(path);
Texture2D texture = new Texture2D(2048,2048);
texture.filterMode = FilterMode.Trilinear;
texture.LoadImage(bytes);
mat[3].SetTexture("_MainTex",texture);
mat[3].SetTexture("_ShadeTexture",texture);
test.GetComponent<SkinnedMeshRenderer>().materials = mat;
}
//オブジェクトが触れている間
void OnCollisionEnter(Collision collision) {
//if (Input.GetKeyDown(KeyCode.Return)) { //Enterキーに調べるコマンドを割り当てる
ChangeCloth();
//}
}
}