Categoryc-sharp

Easy Movie Texture For Android Version: 2.18

Whoever uses the Easy Movie Texture For Android (Video Texture) version 2.18 and also uses split apks (obbs) in unity might run into problems with the streaming asset sub-folders. It’s a great plugin to handle rendered textures on mobile devices.

However the plugin fails to create sub-directories while copying videos out of the obbs into their respective sub-folders. Which can fixed by adding

in the MediaPlayerCtrl.CopyStreamingAssetVideoAndLoad.

So it looks like this:

Also in order to have a e.g. complete callback, simply add a

in the same class and call them at the respective m_CurrentState checks:

I’ve already e-mailed the fix to Lee JaeYun and it will be fixed in a later version presumably, until then use the fix and enjoy.

Unity: Change Build Settings like splash screen, app icon programmatically / dynamically.

For a project at work I needed a way to swap the splash screen, app icon and package name in order to build 8 different themed apps. So here is a way to do it. This script creates a menu entry where you can simply select the specific build and change almost every build setting. Feel free to add any missing qualifier. (UnityEditor.PlayerSettings)

Unity: Start Coroutines on main thread or anything else for that matter

In case you do some asynchronious stuff like updating a game object after a network response in unity, you might come to a point where you want to do something you which can only be done within the unity main thread. So here is a little trick which let’s a certain method be called on the next opportunity of the game loop.

1) Create a gameobject in your scene and add a this script

2) Add your coroutine action into the queue whenever you want to call it like this:

Of course you can add any action to the main queue at any point and whereever you want. Enjoy (:

Java Enums in C#?

I really love C#! Almost all features like delegates, extensions methods, constraints, lambdas, refs, “magic methods”, etc. are really super convinient to use. It’s totally my favorite language so far and trust me I’ve been around with C/C++, Php, Javascript, Java. I pretty much code all the time in C# nowedays.

Probably one feature that Java did way better than C# is the way to extend enums. As stated on this website especially made for java to c# converting people.

Enums are used to create and group together a list of user defined named constants. Although on the surface the enumerated types in C# and Java seem quite similar there are some significant differences in the implementation of enumerated types in both languages. In Java, enumerated types are a full fledged class which means they are typesafe and can be extended by adding methods, fields or even implementing interfaces. Whereas in C#, an enumerated type is simply syntactic sugar around an integral type (typically an int) meaning they cannot be extended and are not typesafe.

You can use enums in Java as collection of concrecte behaviour implementations:

Or have a concrecte amount of certain Objects of a kind like a represenation of different resolutions.

Sure you can do it with normal classes, readonly attributes in c# too. But i was wondering how much of the functionality you could “port” towards c# with the help of generics, extension methods and injected attributes. So this is a small test i came up with the help of some respective stackoverflow articles.

Conclusion

Well it’s far from elegant/readable or even practically usable. However it’s possible to a certain extend. Feel free to correct me.