-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlugin.cs
45 lines (41 loc) · 1.6 KB
/
Plugin.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
44
45
using BepInEx;
using System;
using System.IO;
using System.Reflection;
using UnityEngine;
namespace NameTags
{
[BepInPlugin(PluginInfo.GUID, PluginInfo.Name, PluginInfo.Version)]
public class Plugin : BaseUnityPlugin
{
void Update()
{
foreach (VRRig vrrig in GorillaParent.instance.vrrigs)
{
if (vrrig != GorillaTagger.Instance.offlineVRRig && !vrrig.headMesh.transform.Find("NameTag(Clone)"))
{
GameObject literallynametag = LoadAsset("NameTag");
print(literallynametag.name);
literallynametag.transform.SetParent(vrrig.headMesh.transform, false);
LookAt a = literallynametag.AddComponent<LookAt>();
a.toStare = literallynametag.transform.Find("Canvas").gameObject;
a.text = a.toStare.transform.Find("Name").gameObject.GetComponent<UnityEngine.UI.Text>();
a.who = vrrig;
}
}
}
static AssetBundle assetBundle = null;
public static GameObject LoadAsset(string assetName)
{
GameObject gameObject = null;
if (assetBundle == null)
{
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NameTags.Resources.nametag");
assetBundle = AssetBundle.LoadFromStream(stream);
stream.Close();
}
gameObject = Instantiate<GameObject>(assetBundle.LoadAsset<GameObject>(assetName));
return gameObject;
}
}
}