Answers for "unity switch"

C#
16

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;
        }
    }
}
Posted by: Guest on November-18-2019
3

scene switch unity

SceneManager.LoadScene("SCENE_HERE");

// be sure to import UnityEngine.SceneManagement
Posted by: Guest on February-12-2021
1

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;
}
Posted by: Guest on February-03-2021

C# Answers by Framework

Browse Popular Code Answers by Language