How to enable Unity Collaborate

 In this unity game development tutorial, you learn how to enable Unity Collaborate step by step. This tutorial will show you step by step guide to enable/start unity collaborate in your unity3d projects.

Learn More: Unity Collaborate Limitations/Disadvantages

 Let's get started:

1. Open services

Step # 1 - Open Services

Step # 2: Turn on Collaborate Feature

Step # 3: Select Organization 

Step # 4: Select Organization and Create Project ID

Step # 5: Now Click on Collaborate Toggle



Step #6: Install Collaborate Latest Package.


Step #7: Select File that you want to update on server.

Step # 8: Write comment and publish.




Step # 10: Now you can check history.


Unity WebGL Gzip vs Brotli Compression

 Gzip and Brotli are the two data compression programs that you can use when building for Unity WebGL. If you don't know how to convert your project to unity webgl then feel free to follow my unity webgl conversion guide. You have option in WebGL to choose specific compression format or you can even disable the compression too.

HTML Table

Gzip Brotli
Build files are bigger Build Files siz is smaller
Faster Build time Slow build time
Natively support on all browsers using HTTP/HTTPS Natively support on Firefox & Chrome only with HTTPS

You can check compatibility on caniuse


Read More: Unity WebGL technical Breakdown. 

Go to definition in VSCode not working in PHP

 Go to Definition or F12 is not working in VSCode in PHP environment. The easy solution is to install Php PHP Intelephense

  1. Go to VS code editor.
  2. In editor, Press Ctrl+Shift+X
  3. Extension window will appear on the left side of the editor
  4. On Top search bar, write PHP Intelephense and search
  5. Currently PHP Intelephense 1.7.1 version is appearing. Click on it and install


Now you can go to definition by pressing F12

Unity Collaborate Disadvantages or Limitations

After getting two months of experience with unity collaborate, I am able to highlight some serious problems of Unity collaborate. Or in other words, you can say unity collaborate disadvantages or limitations. 

Learn More: How to Enable Unity Collaborate.

So, without particular order they are given below:

Unity Collaborate Disadvantages/Limitations:

Scene Merging Not Support:

Your scene will be replaced if someone changed the scene on the server and you pull the changes. Your changes will be lost if you are working on the same scene meanwhile you pull all the changes. You have to do some manual work in order to save your work. I found it is better to make a prefab instead of placing your changes or setting in the scene.

Unity Collaborate Project Take Time to Reopen:

        If your project is heavy, heavy means a large project with more files. Then, it will take more time to load. Let say, we open a project that was already on the cloud (collaborate), then it will take time to recheck every file or revalidate the file from the server. Its time consuming and for heavy projects, it takes about half-hour or more.

3.      Unity Collaborate is Slow:

        Collaborate is slow sometimes. It stuck when updating the conflict or changes from the server. Conflict means two users have changed the same file. Then, you have to resolve the conflict either by merging both files or using the server or your file. You can see the difference of the file on third-party tools that unity automatically opens for you if it is already installed.

4.       Changes Some time Not recognized at Scene level:

            I uploaded changes on collaborate, my colleague downloaded the project with the changes but at scene levels, not all changes were sync at his side. At his side, some objects were missing scripts and colliders. It was a very very very strange problem for us (not repeated on other projects). I see that collaborate were not showing any remaining updates. It means that everything was up to date.

5.       Conflict Resolve one by one:

        You have to resolve conflicts one by one.

Encoding 437 data could not be found - Error in Unity3d Build

I was developing a unity3d application that was interacting with excel file using a u3d opensource pacakage. It was working fine in the unity editor. My excel data was showing in editor but after building for windows platform it was not showing excel data in unity anymore. I checked the debug logs of my standalone player and found below error

Uploading Crash Report NotSupportedException: Encoding 437 data could not be found. Make sure you have correct international codeset assembly installed and enabled. at System.Text.Encoding.GetEncoding (System.Int32 codepage) [0x0023f] in :0 at ICSharpCode.SharpZipLib.Zip.ZipConstants.ConvertToString (System.Byte[] data, System.Int32 count) [0x0000e] in <8e8fa28d216a43ec8dcb2258d1f7bf00>:0 at ICSharpCode.SharpZipLib.Zip.ZipConstants.ConvertToStringExt (System.Int32 flags, System.Byte[] data) [0x00022] in <8e8fa28d216a43ec8dcb2258d1f7bf00>:0 at ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry () [0x0014a] in <8e8fa28d216a43ec8dcb2258d1f7bf00>:0 at (wrapper remoting-invoke-with-check) ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry() at NPOI.OpenXml4Net.Util.ZipInputStreamZipEntrySource..ctor (ICSharpCode.SharpZipLib.Zip.ZipInputStream inp) [0x00015] in <09654f5254b44255887f6f774978077f>:0 at NPOI.OpenXml4Net.OPC.ZipPackage..ctor (System.IO.Stream filestream, NPOI.OpenXml4Net.OPC.PackageAccess access) [0x00015] in <09654f5254b44255887f6f774978077f>:0 at NPOI.OpenXml4Net.OPC.OPCPackage.Open (System.IO.Stream in1) [0x00000] in <09654f5254b44255887f6f774978077f>:0 at NPOI.Util.PackageHelper.Open (System.IO.Stream is1) [0x00000] in <6fd7ca6bad364c5ea94149697e721400>:0 at NPOI.XSSF.UserModel.XSSFWorkbook..ctor (System.IO.Stream is1) [0x00026] in <6fd7ca6bad364c5ea94149697e721400>:0 at DataConverters.ExcelToCsvWithNpoi.Convert (System.IO.MemoryStream stream) [0x00015] in <092dda33cb1b4692b34f7feb073574ee>:0 at LoadExcelAndConvertToCsv.OnLoaded (System.IO.MemoryStream stream) [0x0000c] in <092dda33cb1b4692b34f7feb073574ee>:0 at DataLoaders.MemoryStreamLoader+d__0.MoveNext () [0x000e5] in <092dda33cb1b4692b34f7feb073574ee>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in :0 at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in <469e86e97fa2467ebffe49bbd6086325>:0 UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object) UnityEngine.DebugLogHandler:LogException(Exception, Object) UnityEngine.Logger:LogException(Exception, Object) UnityEngine.Debug:LogException(Exception) UnityEngine.WorkRequest:Invoke() UnityEngine.UnitySynchronizationContext:Exec() UnityEngine.UnitySynchronizationContext:ExecuteTasks()

Encoding 437 data could not be found.

After making some research I found that Mono  does not include internalization by default that is required in the standalone application. So, in order to solve the error “Encoding 437 data could not be found. Make sure you have correct international codeset assembly installed and enabled” I have to copy two dlls into my projects plugins folder. The typical location of the dll files is

C:\Program Files\Unity\Hub\Editor\2019.4.27f1\Unity\Editor\Data\MonoBleedingEdge\lib\mono\unityaot

 I was using unity 2019.4.27. So at the unity installation location (given above), copy I18N.dll and I18N.West.dll into the plugins folder. Or you can directly copy it to standalone build under data -> Managed folder.

How Unity call it's MonoBehaviour Method or Events like Update

 Ever wonder how the magic events of unity Behavior works:

void Awake()

{

 

}

 

void Start()

{

 

}

 

void Update()

{

}

// Or other unity magic events like OnEnable, OnDisable, Late Update, Fixed Update, etc.,

The simple answer comes into mind that maybe unity use reflections to find Mono Behaviour methods in order to call it every time or maybe they use override to those methods but apparently, this is not happening. So how it calls its event especially the Update event that calls on every frame.

The way unity3d Messaging system works its:

1.      Unity scripting runtime Mono or IL2CPP access MonoBehaviour derived (type) script.

2.      Look for magic events and cache it.

3.      Like if a MonoBehaviour derived script has an update event then the script will be added into a list (list of scripts) that will be updated on every frame.

4.      Now during gameplay, unity iterates over the list and fire the Unity events. This is the reason that if you make your event public or private they don’t get effected.

 


Library\PackageCache\com.unity.package-manager-ui@1.9.11\Editor\AssemblyInfo.cs could not be found | Solution

You may get dozen of errors like

Library\PackageCache\com.unity.package-manager-ui@1.9.11\Editor\AssemblyInfo.cs could not be found. 

1.       You may get the UI package may error After importing ui package. Now for the solution of the UI Package Manager problem. Follow below steps or watch my below guide:

  1.     Go to Window -> Package Manager
  2.    Click on package Manager UI
  3.    Click to Update the Package

The error will disappear, see the below video:

Library\PackageCache\com.unity.package-manager-ui@1.9.11\Editor\AssemblyInfo.cs Solution

Preview Package is Missing in Unity 2020.3 - Solution

 Unity provides two kinds of packages verified and preview packages. Preview packages are on the development stage therefore, you cannot directly access preview packages (like Job system) in Package manager or its search. Preview package is missing is a config problem that we will resolve in this post: Follow the below steps in order to solve preview package missing problem in Unity3d:

1.       Go to window -> Package Manager

 

 On Package manager windows select the Dropdown (given on left) and select Unity Registry option. (This will provide you the list of available packages provide by unity). Remember it will not include preview packages. Like at the moment Unity Jobs system on the preview stage, if you try to search it then you will unable to find it.


.      

 Now in order to enable preview packages to show in the list. Go to Edit-> Project Settings -> then click on Package Manager.  Now here selects Enable Preview Package checkbox.

     Go back to the Package manager window. Now you can see Preview packages are also showing along with verified packages. Preview packages are clearly visible with preview text in orange color.

5.       Search for your desired package like jobs and you will find the result.

 

2.      

 

3


4.  

                                                                        


Get Request in Unity C# | Get data from a URL in unity

 You often require to access a URL/API endpoint in order to get/post data or communicate to a web server. For this reason, unity provides UnityWebRequest Class. The class specifically designed to handle HTTP communications. It provides set of functions especially Get and Post function to deal with data retrieval and data post operations: Here are the ways to use it:

Get Request: A common way to access data from a URL. Suppose you are trying to get JSON data from a URL/API (given below) and here is our working example URL

https://jsonplaceholder.typicode.com/todos/1

void Start()

    {

        string getURL = "https://jsonplaceholder.typicode.com/todos/1";

        StartCoroutine(GetReq(getURL));

    }

 

    IEnumerator GetReq(string url)

    {

        UnityWebRequest req = UnityWebRequest.Get(url);

        yield return req.SendWebRequest();//wait until request competed

 

        if (req.isNetworkError)//if the networkerror is true then, there is an error.

        {

            Debug.Log("Error While Sending: " + req.error);

        }

        else

        {

            Debug.Log("Received: " + req.downloadHandler.text);

        }

    }


If you have json string then you can deserailze it. Here is the detailed tutorail.

Unity Json Serialization or Deserialization for Beginners

 In this tutorial, you will learn how to convert an object to JSON (JSON serialization) or Deserialization (JSON text to Object). This thing is often helpful to deal with response of reset APIs or database interaction related task or to save or interact with data in unity. Let's learn JSON serialisation in Unity3d step by step:

  1. Make  a class that you want to use as json, for example below I have created score class:

public Scores{

public int playerNo;

public string  playeName;

public string playerScore

}

2.     2.  Now if we want to make it work with JSON serialize. we have to use Serializable attribute in top of the class name

[Serializable]

public Scores{

public int playerNo;

public string  playeName;

public string playerScore

}

3.      3. Create objects of above class:

Scores scores = new Scores();

Scores. playerNo = 1;

Scores. playeName = “Faizan”;

Scores. playerScore = 100;

The object has created and now we are able to convert it to JSON text.

4.     4. To convert the Unity C# Object to JSON string, we can use the built-in static class of Unity named JsonUtility. Here is how it work

String jsonStr = JsonUtility.ToJson(scores);

Note that we have used ToJson method to convert object to JSON. The output of the above string will be like this:

‘{" playerNo ":1," playeName ":faizan," playerScore ":"100"}’

5.       Now if we want to convert the JSON string back to Normal C# Object (deserialization) we can use FromJson method of the same JsonUtility Class

  1. Scores jsonToObject = JsonUtility.FromJson<Scores>(jsonStr)

Not that jsonStr contains the full json string that we made in step 4.

This is smallest way to do JSON seralization and deserializatiin in unity without using any third-party plugins or dependency. If you don't want to use built-in Unity3d c# serialisation classes then you can also use third party plugins or nuGet package like newtonsoft. Here is the way to import newtonsoft DLL in Unity3d.

 

Python: can't open file get-pip.py error | Solution

 One of the common error python developers (new guys) face

python: can't open file get-pip.py error 

 

when they type python get-pip.py in CMD (command line). Despite the presence of the get-pip file in the Python installation folder like python/tools/scripts, we get the error sometimes. The common solution to the get-pip problem is to add your script's folder path into the Path variable.  

 

 


For Mac or Linux users you first required the command:

curl 'https://bootstrap.pypa.io/get-pip.py' > get-pip.py && sudo python get-pip.py

With this easy solution you won't get the issue again.

Unity WebGL Conversion Guide - Steps to consider For Unity Webgl Conversion

 There are some common steps you need to repeat whenever you make Unity WebGL build or if you want to convert your project into WebGL. Beware I am not using Unity 2020.

Learn more: Unity WebGL Technical Breakdown

1. Convert to Latest Unity Version (if Possible):

Always try to use the latest Unity version if you are building for unity WebGL as unity WebGL has several issues. With each new unity release, we see different bug fixes but remember each new build brings it known issues. If you don't have any problem with the latest unity version then, you should adopt it for your WebGL project. Beware porting to your current project into the latest unity version can show significant compatibility issues, so make a backup before conversion.

2. Save Scripting Define Symbols 

Before converting to WebGL please save your scripting define symbol outside unity (separately). Scripting defines symbols will be available under player settings. Some of the symbols are lost during WebGL conversion.
Scripting define symbols in webgl