Question by
ali_siddiqui · Aug 16, 2017 at 10:11 AM ·
triggerbeginnerupdate function
Beginner Question about triggering Update function
So I have this script that causes my game objects to fade in.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OpacityFade : MonoBehaviour
{
[SerializeField] private float fadePerSecond = 2.5f;
public void Update()
{
var material = GetComponent<Renderer>().material;
var color = material.color;
material.color = new Color(color.r, color.g, color.b, color.a + (fadePerSecond * Time.deltaTime));
}
}
I want to trigger this event once I click a UI button (using the HoloLens emulator), so how do I go about creating a custom event that triggers the Update function?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612132824im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do i make part of an object disappear both in rendering and collision with triggers? 1 Answer
Timer onTriggerEnter doesn't launch 0 Answers
2D trigger and mouse button help 0 Answers
How to make different game routes available depending on players previous choice? 0 Answers
Play audio once while condition is met in update function (C#) 2 Answers