Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to add onclick event dynamically in unity

Button button = myButton.getComponent<Button>();
//next, try any of these:
 
//In Unity 5.6 this doesn't work
button.onClick += myMethod;
//Use this instead
button.onClick.AddListener(myMethod);
//Didn't test it
button.onClick.AddListener(delegate{MyMehtod();})
//this will unlikely work
button.onClick.AddListener(() => {MyMethod();});
Comment

PREVIOUS NEXT
Code Example
Csharp :: Return out of a Ienumerator/Courotine in C# 
Csharp :: external font family uwp c# 
Csharp :: allelrt box wpf 
Csharp :: take the last 50 from array c# 
Csharp :: vb.net get double item in list osf string 
Csharp :: how to find all role in mysql 
Csharp :: how to delete dotnet project 
Csharp :: Filter list contents with predicate (anonymous method) 
Csharp :: open full screen wpf 
Csharp :: PasswordBox Helper 
Csharp :: how to make a console feedback 
Csharp :: discord bot c# interrupt CollectReactionsAsync 
Csharp :: c# core deploy on gcp with powershell 
Csharp :: c# timestamp 
Csharp :: check if variable less than in f# 
Csharp :: closedxm Iworksheet excel formulal 
Csharp :: how to make physics in unity 
Csharp :: c# how to load type of class from string 
Csharp :: asp.net disabled checkbox style 
Csharp :: Strings build-in functions in c# 
Csharp :: c# arithmetic operators 
Csharp :: unity get refresh rate 
Csharp :: .net core not returning the sub list 
Csharp :: using selected item in listbox c# to fill texbox 
Csharp :: f sharp functions calling each other 
Csharp :: close windows by esc wpf 
Csharp :: mock return exception c# 
Csharp :: c# prototype function 
Csharp :: c# compare 2 binary files 
Csharp :: button pervious for picturebox c# 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =