Tag Archives: Unity3d

[Unity3d] Serialize and Deserialize System.Guid using JsonUtility

Unity3d 5.3.0 introduced JsonUtility class which will help you with JSON serialization and deserialization. But this class has some limitation, and one of them: “You cannot serialize\deserialize System.Guid type” That’s a pity, especially if you’re using System.Guid in your DTO objects. But, there are solutions: You can change a data type, for example, use System.String or System.UInt32 instead… Read More »

[Unity3d] Yet Another State Machine for Unity3d

If logic in your controller to complex for ‘if’ or ‘switch\case’ constructions, here is small State Machine implementation for you. Let’s start with example how to use this state machine, and then we go through implementation details: public class Test : MonoBehaviour { private StateMachine stateMachine; private State firstState = new State(); private State secondState… Read More »

[Unity3d] How-to play video in Unity project. MovieTexture

If you want to play movie clip in your Unity3d project you need to have Pro version! If you are using Windows machine you also need to have QuickTime installed. After you have everything prepared just drag (or copy) your movie clip into Asset folder, after that you will see it imported. You need a MovieTexture instance… Read More »

[Unity3d] ReadOnly InputField

New UI system was introduced in Unity3d 4.6, it includes InputField control, but this field could not be read only. You can make it non interactable by disabling “Interactable” property in the editor, but then you will not be able to select and copy text from InputField. To have proper ReadOnly input field you should… Read More »

[Unity3d] WaitForFrames in Coroutine

If you are using Coroutines in Unity3d, you probably know about WaitForSeconds, WaitForEndOfFrame and WaitForFixedUpdate classes. Here is an example: public IEnumerator CoroutineAction() { // do some actions here yield return new WaitForSeconds(2); // wait for 2 seconds // do some actions after 2 seconds } But sometimes you need to wait for some amount of frames… Read More »

[How-To] Horizontal Field Of View for Unity3d camera

In Unity3d you can change only vertical field of view for a camera by default. This means whenever you change height unity will automatically scale environment. But if you change width unity will just add some space (or decrease) to left and right side of the screen (no content resizing). If you want to have opposite… Read More »

[Fixed] Error building Player: Win32Exception: zipalign.exe in Unity3d

During building your Unity3d project for Android devices you might get following error:: “Error building Player: Win32Exception: ApplicationName=’C:/Program Files (x86)/Android/android-sdk\tools\zipalign.exe’, CommandLine=’4 “D:\code\Game\Temp/StagingArea/Package_unaligned.apk” “D:\code\Game\Temp/StagingArea/Package.apk”‘, CurrentDirectory=’Temp/StagingArea’” To fix this error: Go to C:\Program Files (x86)\Android\android-sdk\build-tools\20.0.0 (you may have different version) Copy zipalign.exe to C:\Program Files (x86)\Android\android-sdk\tools\ (or in your Android SDK path)