This was OK in Unity 2.0, it’s actually working in 2.1 also, but throwing up error messages as follows:
Console =
"Destroying object immediately is not permitted during physics trigger and contact callbacks. You must use Destroy instead.
UnityEngine.Object:smile:estroyImmediate(Object)
… it’s coming from:
ImageEffectBase:OnDisable() (at Assets/Pro Standard Assets/Image Based/ImageEffectBase.cs:37)
I can change all DestroyImmediate 's for Destroy in the ImageEffectBase.cs and the GlowEffect.cs but then I get the following message:
“Destroy may not be called from edit mode! Use DestroyImmediate instead.
Also think twice if you really want to destroy something in edit mode. Since this will destroy objects permanently.”
… errrr so any ideas which one I should go with? DestroyImmediate or Destroy?
Thank you in advance of any suggestions…
PS. the process is executing OK either way, but I’m wondering if I should ignore the error message in the console or not?
you chould check where you start the app using Application.isEditor or Application.isPlayer and handle the destruction accordingly.
Although this sounds like there is something else wrong as you should never have to mod the source of the code that ships with unity, unless of course you want it to do something different. Did you change anything else in the image effects?
as highlighted above, both ‘DestroyImmediate’ ‘Destroy’ throw up (different) warning messages when in the editor, so yes, I could run a check to see if in editor or not to determine which one to use, but I will still get warnings either way - and I still wouldn’t know which one to use?
I agree with you. I did not change anything in image effects, basically I did not do anything other than switch to version 2.1 - then the warnings came up.
So as a test, I did try replacing all instances of ‘DestroyImmediate’ in ImageEffectBase.cs, and subsequently GlowEffect.cs, for ‘Destroy’ instead. Which gave the other warning, so I’ve reverted back for now.
Therefore I’m guessing this is something that has changing in 2.1, but still…?
@ freyr, yes I reimported the pro asset package manually.
@ Eric, that looks like a near solution for me, however I was using ‘Camera2.gameObject.active’ because “‘enabled’ is not a member of ‘UnityEngine.GameObject’.” ??
as in:-
// Camera Set Up
var Camera1 : GameObject;
var Camera2 : GameObject;
// etc.
function Start () {
// Activate only one camera (we’ll use Camera1 for now).
Sorry, I thought the camera variables were Cameras…probably should make them Cameras rather than GameObjects. But if you don’t want to, then use “Camera1.camera.enabled = false”.
If so, I don’t quite get this as camera’s are game objects right? - I mean you create a camera from the GameObject menu…?
In any case, if I use … Camera1.camera.enabled or Camera1.enabled … does this mean that I will have to now also manually enable / disable multiple audiolisteners, image effect scripts, etc, etc for each camera in turn? I was hoping to find a quicker / more efficient way of this (like I was before by turning off the lot in one call) as I actually have a lot more than 2 cameras going on here.
Yes, I’m wanting to use listeners at the various camera perspective rather than one general one…
Thanks again Eric - your help is much appreciated…
GameObject is the base class for everything, but normally you deal with components, like the camera component. It’s generally faster/more convenient to use the type that you will be referring to most. If you need to refer to the base GameObject, then you can still do “Camera1.gameObject.whatever”. BTW if you’ve defined a variable as a GameObject then you don’t need to do “variable.gameObject.whatever” but just “variable.whatever”.
Pretty much, although to get around this, you can make the cameras separate objects. This way you can do the enable/disable thing on the cameras, which would have nothing on them except the glow script, and then do gameObject.active on the separate objects onto which you can put all the audiolisteners etc. So that would only be slightly less convenient than the way it was before.
Thanks very much for your time Eric, I understand now.
…and that’s a good suggestion re: only doing it this way for the single cameraobject that has a glow-effect and the other way for all other cameraobjects.