Unity Basic Walk Through Monobehaviour Like other fundamental parts such as GameObject, Compoent, Time, Input and Physics, Monobehaviour is an essential member for writing the script, which is the soul of an GameObject. This article HackingWithUnity 8 Mar 2021 · 1 min read
Unity Basic Get game object active status in script It is quite often important to know whether a game object is active or not. bool menuStatus = gameobject.activeSelf; gameObject is the game object in the hierarchy. We can use HackingWithUnity 18 Feb 2021 · 1 min read
Unity Basic Extension Methods Extension Methods are a feature that adding new methods to an existing class, which class is non-generic but static class. Similar to the extension concept in Swift. Features of Extension HackingWithUnity 24 Jan 2021 · 1 min read
Unity Basic Output formatting in C# See the following examples for the formatting on float and date: using System; using System.Globalization; using System.Threading; namespace CSharpLearning { class Program { static void Main(string[] args) { double f HackingWithUnity 7 Jan 2021 · 1 min read
Unity Basic Get time difference between two date In C#, we can easily add or subtract two dates just like numbers. Example of getting how many days, weeks of two dates // Get time difference between two date DateTime HackingWithUnity 5 Jan 2021 · 1 min read
Unity Basic How to create and use Dictionary in Unity using C# Like many other languages, C# does have the dictionary data type: Features of Dictionary in C#: * Not sorted * Key-value pair using System.Collections.Generic; // example of string key and value HackingWithUnity 3 Jan 2021 · 1 min read
Unity Basic How to convert a String to Array in C# Image we have a string: 123,456,78,789, we want to change it to an array, we can use the following code: string szTmp="123,456,78,789"; string[ HackingWithUnity 2 Jan 2021 · 1 min read
Unity Basic Action and Func in C# Actions and func are another ways to create delegates. Action is a delegate that points to a method which in turn accepts one or more arguments but returns no value. HackingWithUnity 27 Dec 2020 · 1 min read
Unity Basic Get mouse input in Unity To get the mouse input event in Unity, we have to create a script attached to your game object. Then add the following script to it: Mouse click using UnityEngine; HackingWithUnity 21 Sep 2020 · 1 min read
Unity Basic Set up global variable in Unity Keep your global variables separately is always a good practice no matter what programming language you are working with. using System.Collections; using System.Collections.Generic; using UnityEngine; public class HackingWithUnity 4 Sep 2020 · 1 min read
Unity Basic Unity Debug int val = 100; Debug.Log("normal log"); Debug.Log("normal log: " + val); Debug.LogWarning("some warning"); HackingWithUnity 25 Aug 2020 · 1 min read
Unity Basic Unity: Countdown Timer Use Coroutine to create a count down timer: private float currCountdownValue = 0; public IEnumerator StartCountdown(float countdownValue = 10) { currCountdownValue = countdownValue; while (currCountdownValue > 0) { Debug.Log("Countdown: " + currCountdownValue); yield return new HackingWithUnity 20 Aug 2020 · 1 min read
Unity Basic Coroutine and simple examples What is coroutine, TL;DR: Simply put, coroutine in Unity is a piece of code (normally a method), and within that code there is a place to pause at each HackingWithUnity 17 Aug 2020 · 1 min read
Unity Basic How to pause the game in Unity The proper way of pausing the game in Unity Time.timeScale = 0; If you want to restore the game: Time.timeScale = 1; HackingWithUnity 11 Aug 2020 · 1 min read
Unity Basic Map, reduce, filter in C# Unity With the help of LINQ, we can easily do some functions like Map, Reduce and Filter like other languages. Map using System.Linq; int[] values = new int[] {1, 2, 3, HackingWithUnity 11 Aug 2020 · 1 min read
Unity Basic String in Unity using C# In Unity, you can either use string or System.String for the string variable. public class PlayerControl : MonoBehaviour { void Awake() { // define a string string s = "foo"; Debug.Log(s); // output: HackingWithUnity 31 Jul 2020 · 1 min read
Unity Basic How to create and use List in Unity using C# How to create and use List in Unity using CSharp HackingWithUnity 29 Jul 2020 · 1 min read
Unity Basic How to create and use ArrayList in Unity using C# How to create and use ArrayList in Unity using CSharp HackingWithUnity 29 Jul 2020 · 1 min read