Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity interfaces

// When you use an interface, you can use two diferent objects to perform one 
// action in common that executes diferently in each of theme.

Interface IDrivable {
	void Drive(); //just the sentence
    //....
}

// Examples of uses:

class Car1 : IDrivable
{ 
	void Drive() {
	//actions to drive the first Car
	}
}

class Car2 : IDrivable
{
	void Drive() {
	//actions to drive the second Car
	}
}

// In this example Car1 and Car2 are diferent classes and each of theme
// drives diferently, but can be used in something like this:

public IDrivable CarToDrive;
CarToDrive.Drive() // this executes Drive() in the selected car, no methers
					// what car is.
Comment

unity run all interfaces

 using System.Linq;   
 ...    
              var ss = FindObjectsOfType<MonoBehaviour>().OfType<IStats>();
              foreach (IStats s in ss) {
                  enemies.Add (s);
              }
Comment

PREVIOUS NEXT
Code Example
Csharp :: what is difference between int.Parse and toint32 in c# 
Csharp :: telerik mvc grid required field 
Csharp :: get web api relative path 
Csharp :: ExpandoObject Syntax that Compile 
Csharp :: c# get executing method name 
Csharp :: how to run a console app in another app c# 
Csharp :: save form in asp.net mvc 
Csharp :: linq dynamic order by descending 
Csharp :: C# Payroll 
Csharp :: c# SQLite execute Command 
Csharp :: REMOVE BOTTOM TAB XAMARIN FORMS 
Csharp :: dotnet target specific framework 
Csharp :: spring jar debug level running 
Csharp :: get access to all controls with a specific tag in C# 
Csharp :: c# check if there is 5 mins space between two datestime 
Csharp :: filter collection viewbag 
Csharp :: boucle C# 
Csharp :: wait for threadpool to complete with decrement 
Csharp :: remove lines from textfile 
Csharp :: Unity Scale per code ändern 
Csharp :: asp.net list find 
Csharp :: how to coppy a portion of an array in c# 
Csharp :: regex ip rage detect c# 
Csharp :: unity remove component 
Csharp :: dotnet core webapp 
Csharp :: copy file 
Csharp :: how to print a variable in c# 
Csharp :: do loop c# 
Csharp :: C# convert random numbers in textBox to currency 
Html :: stylesheet einbinden html5 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =