Home Ask Login Register

Developers Planet

Your answer is one click away!

usama kaleem February 2016

how to implement a third party plugin e.g IAP, Ad Network, Social Sharing with ECS/DOD.

I have started looking into ECS recently for game development. Til now I used and fancied OOP and patterns for code separation, ECS also does so but in another way. I'm getting my head over designing data in ECS. I seems logical for game related stuff.. like Position component Rotation Component Price Component etc in some base building game or any other. but we also have to integrate plugins IAP, Analytics, Social Features, Ad Networks and I'm currently unable to understand how to construct these with ECS only OOP comes in my mind. E.g

  • there can be multiple social features. share on FB, Twitter.
  • Implement different or same adNetowrks for different platforms.

These features can use different plugins/SDKs/Classes for different platforms(IOS, Android, Windows etc).

Im using Unity Game Engine.


Joe Blow February 2016

It's likely this question is too general for SO (I don't necessarily agree with, or understand, the policy but there it is). My answer:

It's likely you're worrying about absolutely nothing.

Almost any project (in any environment) has "infuriating nonsense" you have to add.

You mention for example doing a Facebook Like.

OK, so however annoying it's only a few lines of code.

1) You have a script ("Component") that does just that.

Let's say you have ten such annoying "utility" things in your app -- so, Facebook Like, "put score on Apple high score list", "connect to my home server for data gathering" and so on. infuriating stuff!

2) 100% of Unity projects of course have a "preload" scene. In that scene, you have all your DontDestroyOnLoad items.

(Of course, it's one of the major flaws and complaints about Unity that they annoyingly forgot to "build-in" the idea of a preload scene. 100% of Unity projects have a preload scen, but you just have to click to add a scene manually, name it "preload", and remember to include the DontDestroyOnLoad marker on the objects therein.)

3) So, each of your "utility" components ("scripts") from (1), you simply put on an object in the preload scene.

That's all there is to it.

(The only thing that remains is, you want some syntactical candy to easily access those components. Most teams do it like this


... just using a trivial Static class, that makes it easy to call those "annoying functions". Here is a full code for you ("3 lines of code") to save typing: http://answers.unity3d.com/answers/1124859/view.html

Note that of course, you can't have singletons in Unity (it is a meaningless concept for monobehaviours), so t

Post Status

Asked in February 2016
Viewed 2,137 times
Voted 5
Answered 1 times


Leave an answer

Quote of the day: live life