четверг, 15 июня 2017 г.

When Unity loads obb automagically?

When Unity loads obb automagically? When it resumes from pause. So, UnityObbDownloader plugin works because it starts it's own activity (so unity activity paused) after downloading, unity activity resumes so file is downloaded. Of course, obb loaded automagically at unity app start too.

Which code may be used to force check obb:

(javacode, you need to implement regular android activity in java to do that, you may take com.unity3d.UnityPlayerActivity as example)

Not working code, which you may find all over internet:

1. WWW www = WWW.LoadFromCacheOrDownload("file://" + obbPath, 0);
yield return www;

2. yeild return new WaitForSeconds(3-5);

So, people asking why it's not working for them actually may be not using UnityObbDownloader so no activity, no pause, resume, you've got the point.

It's a shame for Unity that they don't document it anywhere and didn't do a method to check for obb. Because, regular Unity game uses one activity with one UnityPlayer in it and if you download drawing your UI in game style like we all do now you have 2 options after download finish:
1. quit app. On next launch Unity will check for obb and use it
2. trigger pause-resume somehow (invisible activity or code I tested above). Weird

воскресенье, 21 мая 2017 г.

How Unity notifies about innerException: rethrow in stack

Suppose code:

public void TestCodeBelowRxChainExecutedDueExceptionHandled()
                .Select(a =>
                    throw new InvalidOperationException("aa");
                    return a;
                    exception => Debug.LogException(new AssertionFailedException(exception, "mmm assertion failed")); // (*)
            UiLogger.Trace("2"); // not reached if not (*)

четверг, 11 мая 2017 г.

Rx in Unity with favor to synchronous code

Let's look at what rx is. Someone says it's about thinking of asynchronous operations as data flows and of rx operators as flow combining operations - join, merge, concat, transform (select/selectMany), etc. I prefer thinking that way. And yes, rx is somewhat about functional programming, it can be combined with LINQ.

суббота, 6 мая 2017 г.

воскресенье, 9 апреля 2017 г.

Top100 Unity errors

In my programming practice, I encountered many code construction errors. Most worse are hidden. All works, but bugfixing and extending functionality is a nightmare. I will write some which are funny or puzzling in my blog.

1. Created object shows "null" in debugger.

Suppose code:
public class LocationsDB : MonoBehaviour { ... }

locationsDB = new LocationsDB();
Why do you think, debugger can say us, that locationsDB is "null" ?