Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by DocSWAB · Nov 15, 2010 at 05:41 PM · cameraimage-effects

How to switch between variations of the same image effect, or save image effect settings?

I am using an advanced color correction image effect with curves set to particular settings.

I'd like to either be able to attach multiple instances of the image effect to the camera and enable and disable them with a script, or save and reload the curves to and from a variable set.

I haven't seen any obvious ways to reference multiple effects on the same camera. Can I define image effects on different game objects/prefabs and then point the camera to them at runtime? Or copy their contents?

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Herman-Tulleken · Nov 16, 2010 at 09:44 AM

For separate effects you could call GetComponent(WhateverImageEffect) on the camera, then use the enabled property of the component to activate and deactive it.

For instances of the same effect, you could add all the components in your own array, and then use the objects in the array:

WhateverImageEffect[] effects; WhateverImageEffect currentEffect;

public void Start() { effects = GetComponents<WhateverImageEffect>(); currentEffect = effects[0]; currentEffect.enabled = true; //assumes all effects are deactivated on startup.

}

public void SetEffect(int effectIndex) { currentEffect.enabled = false; currentEffect = effects[effectIndex]; }

If you need the order to be the same between runs guaranteed, you could implement your own image effect class, extended from the original, with an extra ID field included. You can then use this to map the effects:

WhateverImageEffectWithID[] effects; WhateverImageEffectWithID currentEffect;

public void Start() { WhateverImageEffectWithID[] tmpEffects = GetComponents<WhateverImageEffectWithID>(); effects = new WhateverImageEffectWithID[tmpEffects .Length];

foreach(WhateverImageEffectWithID effect in tmpEffects ) { effects[effect.ID] = effect; }

currentEffect = effects[0]; currentEffect.enabled = true;
}

public void SetEffect(int effectID) { currentEffect.enabled = false; currentEffect = effects[effectID]; }

For this scheme, the IDs must be assigned by hand (from 0 up to some integer) in the inspector.

Comment
Add comment · Show 6 · 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 DocSWAB · Nov 16, 2010 at 06:34 PM 0
Share

Thanks Herman. $$anonymous$$y situation is that I would have multiple instances of the same image effect. So I probably will have to create an array structure to contain them, and then enable or disable the desired one. I also looked at saving particular settings of the Color Correction Curves filter in a separate object, and then swapping them in and out.

avatar image Herman-Tulleken · Nov 17, 2010 at 06:25 AM 0
Share

@DocSWAB O$$anonymous$$, cool, now I understand. Do you think the order of the objects in GetComponents (the plural) can be relied on? If so, that should be a solution.

avatar image DocSWAB · Nov 17, 2010 at 10:48 PM 0
Share

Probably have to have a separate GO with an array of image effect scripts, and then point one of those to the one on the camera to be the active one (or something like that). You're right in pointing out that you can't count on the order of GetComponents.

avatar image Herman-Tulleken · Nov 18, 2010 at 06:48 AM 0
Share

Here is another idea: Extend your own class from the image effect you want to use, and ad an ID field. You can then use this to track the right component in GetComponents (you could do the mapping on Start, in a separate array that you can user for lookups afterwards).

avatar image Herman-Tulleken · Nov 18, 2010 at 06:50 AM 0
Share

Now that I think about it, if you just use an array on start, you don't need an ID. I'll amend my answer to explain.

Show more comments

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.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Camera Noise Effect Causing Black Screen? 0 Answers

Camera follow help? 1 Answer

Minimap clicking RTS style feature 3 Answers

camera focus on sphere 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