0% found this document useful (0 votes)
12 views2 pages

ToggleCosmeticLikeGorillaTag Cs

This script allows toggling a cosmetic in VRChat using buttons similar to how cosmetics work in Gorilla Tag. It uses coroutines and tags to detect hand collisions and toggle a cosmetic on or off, changing the button material when active. The cosmetic type and name are configured as public variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

ToggleCosmeticLikeGorillaTag Cs

This script allows toggling a cosmetic in VRChat using buttons similar to how cosmetics work in Gorilla Tag. It uses coroutines and tags to detect hand collisions and toggle a cosmetic on or off, changing the button material when active. The cosmetic type and name are configured as public variables.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System.

Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.VR;
using Photon.VR.Cosmetics;

public class ToggleCosmeticLikeGorillaTag : MonoBehaviour


{

[Header("Gtag like Script")]


[Header("By HuhMonke no need for creds i just want u guys to have fun")]
public CosmeticType CosType;
public string CosmeticName;
public string HandTag = "HandTag";
private bool enabledd = false;
private bool disabled = true;
public float WaitBeforeCanUseAgain = 1f;
[Header("Set This Gameobject to your button so it can change color when
pressed")]
public GameObject Button;
public Material red;
public Material white;
private bool isWaiting = false;

// Start is called before the first frame update


void Start()
{

// Update is called once per frame


void Update()
{
}
private void OnTriggerEnter(Collider other)
{
if(disabled && other.CompareTag(HandTag))
{
enablehecosmetics();
}
else if(enabledd && other.CompareTag(HandTag))
{
disablehecosmetics();
}

IEnumerator enableCosmetic()
{
isWaiting = true;
cosmeticStart();
Button.GetComponent<Renderer>().material = red;
yield return new WaitForSeconds(WaitBeforeCanUseAgain);
enabledd = true;
disabled = false;
isWaiting = false;
}
IEnumerator dsisableCosmetic()
{
isWaiting = true;
cosmeticno();
Button.GetComponent<Renderer>().material = white;
yield return new WaitForSeconds(WaitBeforeCanUseAgain);
disabled = true;
enabledd = false;
isWaiting = false;
}
void enablehecosmetics()
{
{
if (!isWaiting)
{
StartCoroutine(enableCosmetic());
}
}
}
void disablehecosmetics()
{
{
if (!isWaiting)
{
StartCoroutine(dsisableCosmetic());
}
}
}
void cosmeticStart()
{
PhotonVRManager.SetCosmetic(CosType, CosmeticName);
}
void cosmeticno()
{
PhotonVRManager.SetCosmetic(CosType, "");
}
}

You might also like