c#

Singleton : Implementation in Unity3d C#

Objective : Singleton is a very complex topic, In this, we try to understand basics and various implementation of Singleton in Unity3d using C#. Intro: Singleton is a basic Design Pattern. Classes implementing Singleton pattern will ensure that only one instance of the object ever exists at any one time. It is recommend using Singletons for things that do not need to be copied multiple times during a game.This is great for controller classes like GameManager or AudioController. Implementation: There are several ways of implementing Singleton in Unity, we will some of the implementation in this tutorial Simplest Implementation Above code is the simplest implementation of Singleton, but there are some issues which we have to address Singleton is not persistent across the Unity scenes. All the executable code must be attached to GameObject in the hierarchy. It is not recommended to call SingletonController.Instance in any Awake() method because, since we don’t know the…

c#

Difference Between Destroy and DestroyImmediate Unity Functions

Objective : Objective of this Tutorial is to understand diffence between Destroy and DestroyImmediate unity function Purpose of both function is same, to destoy gameobject, but there is very small difference, which is very crucial to understand, wrong use of these function can cause your app to crash So first of all little bit of theory and then some code Destroy() :  This just destroy the game object passed as parameter.  It set all the references to that game object to null at the end of frame. Syntax: Destroy(myGameObject); Let see it in code: Create new script and add this code and add it to Main Camera and click play, and just left click to create new game object and press space bar to destroy the game object and check the log in console window you will notice that first log print the status “true“, and second log print the name of currObject which…

c#

Unity Interview Questions

In this, I am going to list some of the very commonly asked interview questions for unity developer profile. Unity Engine Specific Question : Difference between Update,Fixed Update and Late Update. What is Prefabs in Unity 3D? What is the use of AssetBundle in Unity? What is difference between Resources and StreamingAssets Folder. What is Batching and what is the use of Batching? Difference between Destroy and DestroyImmediate unity function Difference between Start and Awake Unity Events What is the use of deltatime? Is this possible to collide two mesh collider,if yes then How? Difference between Static and Dynamic Batching. What is the use of Occlusion Culling? How can you call C# from Javascript, and vice versa? Arrange the event functions listed below in the order in which they will be invoked when an application is closed: Update() OnGUI() Awake() OnDisable() Start() LateUpdate() OnEnable() OnApplicationQuit() OnDestroy() C# related Questions :  Difference between…

Google Cardboard

How to Build Google Cardboard VR Game using Unity part -1

Unity made it very easy to create VR apps, and with cardboard, it is just super easy. Unity 5.1 onwards contains built-in support for certain VR devices, but for that, you require Unity pro licence.   So Why Cardboard ? Because it is cheapest VR Device available in the market. it cost you only $10- $20, and you do not need Unity pro licence for that. other options for virtual reality devices                                          all are very expensive and some are not easily available to the user. On the other hand google Cardboard works with most modern Android phones and iPhone. Phones need to be running Android 4.1 (Jelly Bean) or above. Ideally should have a gyroscope, most important there are tons of apps available. Prerequisites Unity – At least v5.1 is…