Skip to main content

Posts

Showing posts from May, 2019

Unity Native Toast - Technoob Technology

Unity engine is an awesome game engine but it doesn't contain a toast system within its API. In this article, you gonna learn how to create a toast system like the native Android toast system in Unity Engine. To accomplish this we need a tween engine and for this tutorial, we are using LeanTween which is available in the Unity asset store for free. You can change this to whatever tween engine you would like to use. Let's get started.  This module contains only a single script and pretty easy to understand. Let's call the class as 'Toast' to give a taste of what this is for. First, we need to create canvas prefab with a rounded rectangle and a text element. Then We create the script called Toast and this should be a singleton in order to keep this toast canvas in every scene without destroying. The singleton pattern is simple and what it does is check if there is another toast canvas and if there is another one destroys the current o

Unity Get Post web requests - Technoob Technology

Web requests in unity are super easy to use. We gonna use the UnityWebRequest class as the WWW class is deprecated now. UnityWebRequest class can be used for both Get and Post methods. The 'UnityEngine.Networking' namespace is required to work with UnityWebRequests.  This tutorial is made with some simple UI elements. First Let's see how the GET method works. 01. UnityWebRequest.GET We use this method to receive data from the server as normal get requests. Using coroutines in web requests is mandatory as we have to wait until the download is complete before showing the results, and the coroutines make this much easier. A simple button calls the method and a text element will show the result. The script contains a reference to the text element and the string URL of your PHP file.  When the button is pressed the button executes the ButtonGetData method and that method simply starts the GetData coroutine. We use the using keyword as this data

Object Pooling system for unity - Technoob Technology

As a game developer, you might have experienced performance issues when instantiating new game objects in a  game. This is a very usual thing as instantiating an object in the middle of the game costs a severe amount of  CPU power. Professional game developers use various methods to avoid instantiating objects like this. Pooling is  the most popular method to do this. We gonna target unity engine in this tutorial and this class is created in C# language.  A pool is a set of instantiated game objects but disabled. When a class or method requires a game object of that type  pool simply takes one of the game objects from the pool and returns it. We can create pools within each class and that is going to be  very hard to manage and time wasting as you have to rewrite the same code again and again. To avoid this we are going to create a  custom class called Pool and implement all the functions a pool should contain within it.  As we mentioned above the class is named as