Cyber Week Mega Sale
Save up to 50% on thousands of assets
Learn More

Ternary Operator

Tutorial
Intermediate
5 Mins
Overview
Details
Your progress
Also included in
Summary
How to utilize the Ternary Operator to build simple, shorthand IF-ELSE logical conditions.
Recommended Unity versions
4.3 and Above
Topics we'll cover
Industry
Language
English
Tutorial
Ternary Operator
0

1.Ternary Operator


TernaryOperator
using UnityEngine; using System.Collections; public class TernaryOperator : MonoBehaviour { void Start () { int health = 10; string message; //This is an example Ternary Operation that chooses a message based //on the variable "health". message = health > 0 ? "Player is Alive" : "Player is Dead"; } }

Ternary Operator
Comment Guidelines
General Tutorial Discussion
0
0
1. Ternary Operator
0
0