Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to write switch statement unity

using UnityEngine;
using System.Collections;

public class ConversationScript : MonoBehaviour 
{
    public int intelligence = 5;
    
    
    void Greet()
    {
        switch (intelligence)
        {
        case 5:
            print ("Why hello there good sir! Let me teach you about Trigonometry!");
            break;
        case 4:
            print ("Hello and good day!");
            break;
        case 3:
            print ("Whadya want?");
            break;
        case 2:
            print ("Grog SMASH!");
            break;
        case 1:
            print ("Ulg, glib, Pblblblblb");
            break;
        default:
            print ("Incorrect intelligence level.");
            break;
        }
    }
}
Comment

unity switch

public float number;

switch(number)
{
case 1: 
Debug.Log("1");
break;
case 2:
Debug.Log("1");
break;
default: //case that happens if no case matches
Debug.Log("I dont know");
break;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity c# check how many of an object exists 
Csharp :: unity pick random number 
Csharp :: rotate player unity 2d left and right 
Csharp :: c# move files from one folder to another 
Csharp :: selection sort in c# 
Csharp :: c# dictionary to json 
Csharp :: asp.net file detect mime type 
Csharp :: c# print list 
Csharp :: what does static mean in c# 
Csharp :: decimal c# 2 digits 
Csharp :: unity round float to nearest 10 
Csharp :: how to move object with keyboard in unity 3D 
Csharp :: c# access session in class 
Csharp :: how to import datagridview to datatable in c# 
Csharp :: c# xor byte array 
Csharp :: increment operator c# 
Csharp :: convert string to number c# 
Csharp :: how to stop animation unity 
Csharp :: c# concatenation 
Csharp :: relative path c# 
Csharp :: public gameobject unity 
Csharp :: c# string interpolation 
Csharp :: destroy the game object if the animator has finished its animation 
Csharp :: c# settings file 
Csharp :: google script get time 
Csharp :: c# remove char from string 
Csharp :: copy class c# 
Csharp :: how to print statement in c# 
Csharp :: c# get list item in random order 
Csharp :: how to concert a list into strinf splitted by coma c# 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =