ipsilondev / openfl-unityads

UnityAds implementation for OpenFL/Haxe
MIT License
16 stars 1 forks source link

How to use start() function? #1

Closed glockling closed 9 years ago

glockling commented 9 years ago

Checking out the readme I'm not quite sure I understand how to use the start() function.

Sorry if it's a noob question, I'm new to this and trying to learn.

shadowofsoul commented 9 years ago

no problem. actually there is not start() function. the only functions that you can execute are init() and showAd(). they are in the example in the readme. the catch, is that before you call any of them, you need to listen to the events. there are several events, the same that exists in the unity ads documentation (https://unityads.unity3d.com/help/Documentation%20for%20Publishers/Integration-Guide-for-Android ) , but the one is required to listen, is UnityAds.onFetch, that is fired after you call to UnityAds.init(). that event would return if the ads are ready to be shown or not, and then you can call UnityAds.showAd() to actually show the ad. optional, you can listen to several events, like onVideoCompleted, onVideoHide etc... if you need.

glockling commented 9 years ago

Alright I got it but like you said in the readme to import the bundle to your resources where is the resources folder? Because I'm not sure if I'm putting it in the right spot since it keeps crashing.

shadowofsoul commented 9 years ago

yes, that only applies to the iOS version. the problem is that none of the haxe or openFL tags allows to include that in the xCode project automatically. after you do the command "lime build ios" in your project, you must open the xCode project, and you will see in the left margin, 4 folders, one of them is called Resources. then, you must drag from the finder window, the .bundle file ( located here https://github.com/ipsilondev/openfl-unityads/tree/master/frameworks ) and drop it on top of the Resources folder inside xCode, then you can hit build / run in xCode to build the app again with the bundle inside. if you have already done this, let me know what errors is throwing in the xCode console at running your game, so i can help you further on this matter.

shadowofsoul commented 9 years ago

quick note, every time you do a lime build ios, you are needed to re-do the drag and drop operation, as the xCode project is regenerated and the reference is lost (is a pain, but for now there is not other solution). another important thing, is that extensions only work with openFL version before 3.0.0 or with 3.0.0 but using the legacy tag (i haven't tested it with legacy tag really, but is supposed that sould work)

glockling commented 9 years ago

I think the problem here, is that I'm actually using Stencyl but I'm creating an extension for it using your methods. http://stencyl.com

So when I open up xcode and drag it in and then try building again Stencyl just erases the stupid thing. Do you know where the build file goes when I drag it into my resources folder? Is it pre-determined by xcode or is it determined by me/stencyl?

glockling commented 9 years ago

I think Stencyl is using version 2.X with Openfl

glockling commented 9 years ago

So I've added it to my assets folder which is inside "resources" but still nothing?

http://puu.sh/h6tDG/81bc98917d.png

glockling commented 9 years ago

Is it possible to take the files outside of the .bundle and just throw them into the assets folder? So we don't have to deal with the .bundle

glockling commented 9 years ago

You know what, don't worry about it. I've got Chartboost and Admob so I'm good I guess.

shadowofsoul commented 9 years ago

well, the problem is really complicated, for what we could research, xCode created a reference in the project settings, but even after joshua (openFL creator) tried to replicate the reference, still didn't work (you can see it here: http://community.openfl.org/t/how-to-include-a-bundle-file-in-the-resources-folder-when-doing-a-extension-ios/916/4 ). the option of include the .bundle in the assets folder didn't work, i already tried it. i'm open my test project on the Mac to compare it with your screenshot, if you wait a couple of minutes, i'll give you an answer.

glockling commented 9 years ago

Hm okay, even if you could figure out something like just extracting the files from the bundle which are some images and a plist and somehow linking that to assets? If that makes sense. I think that would be easier than having to import a bundle everytime.

shadowofsoul commented 9 years ago

could be, but really that exceeds my iOS knowledge by far, plus, it must be integrated to the Lime building process, something i can't do really.

i re-tested this under a clean build, it worked . i'm using the same build that you got from haxelib and OpenFL 2.2.8. maybe stencyl is doing something extra to the project and that's why it doesn't work. the file should look like this after you include it in xCode:

if you have any more info from xCode console, i can help you further, but whiteout something else, i can't tell you what could be wrong, sorry.

glockling commented 9 years ago

I'm going to pop a question in there and see if it's possible to do something like that without it getting erased. Because I'll add it in to my xcode project and then when I click build is reverts back to the original xcode format. So. . . Idk, i'll just find out.