• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Demigiant · Mar 21, 2011 at 11:38 AM · itweenfade

iTween CameraFade not working in some cases (related to camera's cullingMask)

Hello,

I'm at a loss here...

What I'm trying to do

Animate the fading from one camera to another (in the same scene), with iTween (v2.0.43) and Unity Pro 3.3.

How I'm doing it

  1. I create a Texture2D, w$$anonymous$$ch contains the current view snapshot.
  2. I assign it to iTween using iTween.CameraFadeAdd( tex_fadeFrom ).
  3. I change the active camera to the new one I wish to use.
  4. I start the tween.

Code is here (I'm not writing the code I use to take a Texture2D snapshot of the view, because the problem is not there: it's working perfectly):

// Here I store the current camera snapshot.
// tex_fadeFrom is a private property.
// HVCameraUtils.getViewScreenshot is the method
// that creates the Texture2D from the current view.
tex_fadeFrom = HVCameraUtils.GetViewScreenshot();
// T$$anonymous$$s calls a setter w$$anonymous$$ch changes
// the main camera to the one I wish to fade to.
Vars.activeCam = Vars.isolationCam;
// iTween.
iTween.CameraFadeAdd( tex_fadeFrom );
Hashtable tw = new Hashtable();
tw.Add( "amount", 1 );
tw.Add( "time", 0.7f );
tw.Add( "oncomplete", "Isolate_fadeComplete" );
tw.Add( "oncompletetarget", t$$anonymous$$s.gameObject );
iTween.CameraFadeFrom( tw );

The problem

All works perfectly, until I change the culling mask (via the camera's Inspector) of the secondary camera (isolationCam).

If the culling mask contains some of Unity's default layers, the animation plays correctly. Otherwise (like in t$$anonymous$$s case, in w$$anonymous$$ch the culling mask is set to layer 30 alone), the cameras switch correctly, but the fade animation doesn't play (tex_fadeFrom never appears and fades out: simply put, the secondary camera appears immediately). Or better: I can see the animation in the scene view (!), where tex_fadeFrom appears and fades out, but not in the game view.

Please help! :P

Comment
Thom Denick

People who like this

1 Show 0
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Thom Denick · Jan 14, 2012 at 07:35 PM

I know t$$anonymous$$s is a pretty old question, but I just ran into t$$anonymous$$s problem and resolved it. Basically when iTween creates its camera Fade Texture, it puts it on the "Default" layer. So if your Camera is culling out "Default" you won't see the fade. You can see t$$anonymous$$s pausing your game w$$anonymous$$le it is running in the editor and look for the iTween Camera Fade Object.

Unfortunately, it doesn't seem as though Mr. $$anonymous$$ebile programmed a way to easily change the Layer of the texture (just the depth). As such there isn't an easy way to get a reference to the object and change it's layer. I just added Default to the masks on my cameras as I don't really have anyt$$anonymous$$ng important sitting in that layer anyway. I would imagine you could also search for the object's name: "iTween Camera Fade" and get a reference that way.

Update After realizing I do indeed have objects on my default layer, I went back and coded it as described above. Here's the code solution as I have it:

 private void Awake() {
   iTween.CameraFadeAdd (LoadingTexture, 5000);
   findAndChangeCameraFadeObjectLayer();
 }

 private void findAndChangeCameraFadeObjectLayer() {
     GameObject cameraFadeObject = GameObject.Find ("iTween Camera Fade");
     if(cameraFadeObject)
         cameraFadeObject.layer = 16;
 }
Comment
Demigiant
animalphase

People who like this

2 Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Demigiant · Jan 14, 2012 at 08:47 PM 0
Share

Thanks a lot Smorpheus. Actually, I ended up fading the camera without iTween - it was the first step towards what's now HOTween: my egotistical tween engine (http://hotween.holoville.com, if you're curious - though there's no direct "cameraFade" method, I just created snapshots and tweened some field).

avatar image Thom Denick · Jan 16, 2012 at 04:46 AM 0
Share

Awesome, iTween frequently frustrates me. I'll take a look at your package on my next project. Are you going to post it in the Asset Store?

avatar image Demigiant · Jan 16, 2012 at 02:32 PM 0
Share

I'll post it in the Asset Store within the end of the month, I suppose. And I just made it open-source via Google Code (http://code.google.com/p/hotween). Though I have to note that it's not a "better" engine than iTween: it's simply very different and truly object-oriented (and type-safe), and definitely suits more my coding tastes :)

avatar image Thom Denick · Jan 16, 2012 at 08:08 PM 0
Share

Yes, well I'm not particularly a fan of the Hash system. So if it's OO && type-safe that's probably good enough for me to switch. :) I much prefer the TweenParms object just for sanity. Also the Google Code URL is bad.

avatar image Demigiant · Jan 16, 2012 at 08:29 PM 0
Share

Oops, sorry, the comment took hold of the last parenthesis and added it to the url :P Here it is again: http://code.google.com/p/hotween

And glad you like TweenParms: I tested and implemnted a lot (uh, not that lot: 2 other) of alternative ways, before finally deciding for that :)

avatar image

Answer by ChiuanWei · Aug 19, 2011 at 12:38 AM

because the Texture2D u Get ,base on that culling mask.when your culling mask is set to layer 30 alone. Texture2D is not$$anonymous$$ng, so .you can't see anyt$$anonymous$$ng~~

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by netlander · Jul 26, 2013 at 06:26 PM

I have a similar problem where iTween.CameraFadeTo works for a w$$anonymous$$le then it stops fading for no apparent reason, t$$anonymous$$s happened twice on two different projects when all of a sudden fading stop occurring.

My code is very simple, no culling masks involved.

         // First I setup the fade
 
     void Start () {
         iTween.CameraFadeAdd(fadingScreen, 99999);
     }
 
     // Then I do the fade (in a different method)
     iTween.CameraFadeTo(iTween.Hash...));
 

It works for a w$$anonymous$$le then out of the blue kaboom!

After looking at the "iTween Camera Fade" I noticed that when the fade works the GUITexture contains the fadingScreen. In the case when it's not working the GUITexture is empty.

Why would the "iTween Camera Fade" loose the fadingScreen I setup or even the default one without any reason? Could it be a bug?

Any help is much appreciated. Paul

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to best optimise this script 1 Answer

how to move or fade GUITextures with iTween 2 Answers

Fading out alpha on a 3d object with iTween 0 Answers

Fade in object using iTween 0 Answers

iTween :: fading out an empty with Children 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges