prime31 / TransitionKit

Modular, extensible transitions in scene and between scenes
304 stars 55 forks source link

onScreenObscured called too soon. #6

Closed aidinzolghadr closed 8 years ago

aidinzolghadr commented 8 years ago

Hi,

First of all, thank you for yet another great asset.

I want to fade the screen out to black and when it's completely black, reload my scene and then screen would fade in. I think I should use onScreenObscured and I've added my reload function to it with += operator.

My issue is that my function gets called as soon as the fade starts. Here is my code:

    var fader = new FadeTransition()
    {
        fadedDelay = 10.0f,
        fadeToColor = Color.black
    };
    TransitionKit.instance.transitionWithDelegate(fader);

    TransitionKit.onScreenObscured += LoadNextRound;

Thanks

prime31 commented 8 years ago

onScreenObscured is fired the moment the screen is obscured by the screen capture, so everything is happening as expected. Once the screen is obscured you can modify it anyway that you need to.

Mike

On Tue, Sep 15, 2015 at 8:47 AM, Aidin Zolghadr notifications@github.com wrote:

Hi,

First of all, thank you for yet another great asset.

I want to fade the screen out to black and when it's completely black, reload my scene and then screen would fade in. I think I should use onScreenObscured and I've added my reload function to it with += operator.

My issue is that my function gets called as soon as the fade starts. Here is my code:

var fader = new FadeTransition()
{
    fadedDelay = 10.0f,
    fadeToColor = Color.black
};
TransitionKit.instance.transitionWithDelegate(fader);

TransitionKit.onScreenObscured += LoadNextRound;

Thanks

— Reply to this email directly or view it on GitHub https://github.com/prime31/TransitionKit/issues/6.

aidinzolghadr commented 8 years ago

I want my method gets called when the screen is full pitch black, not when it starts to fade out. Can I achieve this?

On Tuesday, September 15, 2015, Mike notifications@github.com wrote:

onScreenObscured is fired the moment the screen is obscured by the screen capture, so everything is happening as expected. Once the screen is obscured you can modify it anyway that you need to.

Mike

On Tue, Sep 15, 2015 at 8:47 AM, Aidin Zolghadr <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

Hi,

First of all, thank you for yet another great asset.

I want to fade the screen out to black and when it's completely black, reload my scene and then screen would fade in. I think I should use onScreenObscured and I've added my reload function to it with += operator.

My issue is that my function gets called as soon as the fade starts. Here is my code:

var fader = new FadeTransition() { fadedDelay = 10.0f, fadeToColor = Color.black }; TransitionKit.instance.transitionWithDelegate(fader);

TransitionKit.onScreenObscured += LoadNextRound;

Thanks

— Reply to this email directly or view it on GitHub https://github.com/prime31/TransitionKit/issues/6.

— Reply to this email directly or view it on GitHub https://github.com/prime31/TransitionKit/issues/6#issuecomment-140444886 .

prime31 commented 8 years ago

I'm not sure I understand. Once the screen is obscured (i.e. a screen capture has finished) that is your queue to do whatever you want with the scene graph since it won't be rendered anymore. I just don't understand why you would want to wait for a transition to be half over before modifying the scene graph. It seems like wasted time especially since TransitionKit uses additive scene loading.

I don't see any reason why something like that would be a part of TransitionKit proper but if you insist on delaying your async scene loading just make your own FadeTransition and do whatever you want in it. One of the main purposes of TransitionKit is that you can make your own transitions very easily to do anything at all that your heart desires.

aidinzolghadr commented 8 years ago

The reason is that I when I call my LoadNextRound callback function, it changes the position of objects in the scene and I don't want the player to see this, that's why I want to be able to call this function when fade out happened completely and screen is dark and when my LoadNextRound call is complete, it would resume and fade in.

Also please note that I'm not loading another scene or any scene at all, I just want to have a moment to re adjust the level for another round of gameplay.

prime31 commented 8 years ago

When onScreenObscured is called the screen is already obscured. That is the entire reason the event is fired.

Mike

On Sep 16, 2015, at 2:52 AM, Aidin Zolghadr notifications@github.com wrote:

The reason is that I when I call my LoadNextRound callback function, it changes the position of objects in the scene and I don't want the player to see this, that's why I want to be able to call this function when fade out happened completely and screen is dark and when my LoadNextRound call is complete, it would resume and fade in.

— Reply to this email directly or view it on GitHub.

aidinzolghadr commented 8 years ago

That's what I wrote in my first post, it won't get fired when screen is completely black. onScreenObscured is called as soon as the transition starts, i.e. starting to fading out.

prime31 commented 8 years ago

Correct. It gets fired the moment the screen is obscured. Add a Debug.Break() call to the event and examine the scene. That should clear things up for you.

Mike

On Sep 17, 2015, at 3:44 AM, Aidin Zolghadr notifications@github.com wrote:

That's what I wrote in my first post, it won't get fired when screen is completely black. onScreenObscured is called as soon as the transition starts, i.e. starting to fading out.

— Reply to this email directly or view it on GitHub.

aidinzolghadr commented 8 years ago

I did what you suggested and as soon as transition starts, onScreenObscured gets called. Here is my full code:

void OnEndRoundEvent(EndRoundEventStruct endRoundEventStruct)
{
    Debug.Log(endRoundEventStruct.roundWinnerPlayerController.PlayerId);

    TransitionKit.onScreenObscured += onScreenObscured;
    TransitionKit.onTransitionComplete += onTransitionComplete;

    var fade = new FadeTransition()
    {
        //duration = 2.0f,
        fadedDelay = 0.2f,
        fadeToColor = Color.black
    };
    TransitionKit.instance.transitionWithDelegate(fade);
}

void onScreenObscured()
{
    Debug.LogError("Screen is black?");
}

void onTransitionComplete()
{
    Debug.LogError("Transition is over?");
}

BTW I'm using Unity 5.1.1 x64 on Windows.

Edit1: I even tried modifying the example that came with TransitionKit and removing the scene transition and added a break in onObscureScene with the fader, it has the same bug.

Edit2: I think what onObscureScene means for different effects should vary. For example, some of your effects obscure the scene as soon as they start but some of them like fade will take sometime to fill/obscure the scene with the color.

I've read your code and from what I understood, you call the onObscureScene method call as soon as the transition starts while what I want is to have control on half way of the fade so I can change camera and other stuff.

But as I said, where this onObscureScene gets called should be different from transition to transition.

Edit3: I wanted to write my own fade to have this feature that I wanted but have no clue what to do since you call onObscureScene as soon as the transition starts.

prime31 commented 8 years ago

Put a Debug.Break call in there. I don't think you are fully understanding what TransitionKit is doing and breaking at that point will let you examine the scene thoroughly. Move some objects around while its paused. Delete some. Add some. You'll notice nothing you do is visible.

Mike

On Sep 19, 2015, at 3:20 AM, Aidin Zolghadr notifications@github.com wrote:

I did what you suggested and as soon as transition starts, onScreenObscured gets called. Here is my full code:

void OnEndRoundEvent(EndRoundEventStruct endRoundEventStruct) { Debug.Log(endRoundEventStruct.roundWinnerPlayerController.PlayerId);

TransitionKit.onScreenObscured += onScreenObscured;
TransitionKit.onTransitionComplete += onTransitionComplete;

var fade = new FadeTransition()
{
    //duration = 2.0f,
    fadedDelay = 0.2f,
    fadeToColor = Color.black
};
TransitionKit.instance.transitionWithDelegate(fade);

}

void onScreenObscured() { Debug.LogError("Screen is black?"); }

void onTransitionComplete() { Debug.LogError("Transition is over?"); } — Reply to this email directly or view it on GitHub.

cubicme commented 8 years ago

(aidinzolghadr here) Oh I get it now and what you meant by "obscure".

I think I'm better of with transitions with what I want to achieve, but good to know how things work here. You may want to describe it for others.

Thanks.