-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathAvatarData.cs
43 lines (34 loc) · 1.12 KB
/
AvatarData.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
36
37
38
39
40
41
42
43
using System;
using UnityEngine;
namespace ReadyPlayerMe.Core
{
public class AvatarData : MonoBehaviour
{
public string AvatarId;
public AvatarMetadata AvatarMetadata;
private SkinnedMeshRenderer[] meshes;
private void Awake()
{
meshes = GetComponentsInChildren<SkinnedMeshRenderer>();
}
private void OnDestroy()
{
foreach (var mesh in meshes)
{
var materials = mesh.sharedMaterials;
foreach (var material in materials)
{
if(material == null) continue;
foreach (var property in material.GetTexturePropertyNames())
{
Texture texture = material.GetTexture(property);
if(texture == null) continue;
Destroy(texture);
}
Destroy(material);
}
Destroy(mesh.sharedMesh);
}
}
}
}