Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 Henderikus-Parekowhai · Jan 24, 2017 at 05:20 AM · getcomponentvariableschange variable

Cannot Edit variables?

So im having an issue editing a variable via another script. Im trying to edit the contrast public float, how would i do this.

ive tried "using UnityStandardAssets.CinematicEffects; mainMenuCamera.GetComponent ().BasicsSettings.contrast" but that doesnt work.

I dont know what im doing wrong. can anyone help me? i pretty new to programming and any help would be awesome. Sorry again for my newbieness. here is the first section of the contrast script. Not sure if more of the script is needed, if so just ask for it and ill post it :)

 namespace UnityStandardAssets.CinematicEffects
 [Serializable]
             public struct BasicsSettings
             {
                 [Range(-2f, 2f), Tooltip("Sets the white balance to a custom color temperature.")]
                 public float temperatureShift;
     
                 [Range(-2f, 2f), Tooltip("Sets the white balance to compensate for a green or magenta tint.")]
                 public float tint;
     
                 [Space, Range(-0.5f, 0.5f), Tooltip("Shift the hue of all colors.")]
                 public float hue;
     
                 [Range(0f, 2f), Tooltip("Pushes the intensity of all colors.")]
                 public float saturation;
     
                 [Range(-1f, 1f), Tooltip("Adjusts the saturation so that clipping is minimized as colors approach full saturation.")]
                 public float vibrance;
     
                 [Range(0f, 10f), Tooltip("Brightens or darkens all colors.")]
                 public float value;
     
                 [Space, Range(0f, 2f), Tooltip("Expands or shrinks the overall range of tonal values.")]
                 public float contrast;
     
                 [Range(0.01f, 5f), Tooltip("Contrast gain curve. Controls the steepness of the curve.")]
                 public float gain;
     
                 [Range(0.01f, 5f), Tooltip("Applies a pow function to the source.")]
                 public float gamma;
     
                 public static BasicsSettings defaultSettings
                 {
                     get
                     {
                         return new BasicsSettings
                         {
                             temperatureShift = 0f,
                             tint = 0f,
                             contrast = 1f,
                             hue = 0f,
                             saturation = 1f,
                             value = 1f,
                             vibrance = 0f,
                             gain = 1f,
                             gamma = 1f
                         };
                     }
                 }
             }
    
 
 
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
0

Answer by sohail11330 · Jan 24, 2017 at 08:57 AM

change public float Contrast to public static float Contrast. Use GetComponent< contrast script name>().contrast; in your script or where you want to use contrast value.

Comment
Add comment · Show 2 · 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 Henderikus-Parekowhai · Jan 24, 2017 at 09:56 AM 0
Share

it dosent work, im getting 3 errors,

"Assets/Standard Assets/Effects/TonemappingColorGrading/TonemappingColorGrading.cs(281,25): error CS1914: Static field or property UnityStandardAssets.CinematicEffects.TonemappingColorGrading.BasicsSettings.contrast' cannot be assigned in an object initializer" "Assets/Standard Assets/Effects/TonemappingColorGrading/TonemappingColorGrading.cs(281,25): error CS0176: Static member UnityStandardAssets.CinematicEffects.TonemappingColorGrading.BasicsSettings.contrast' cannot be accessed with an instance reference, qualify it with a type name ins$$anonymous$$d"

"Assets/Standard Assets/Effects/TonemappingColorGrading/TonemappingColorGrading.cs(974,94): error CS0176: Static member `UnityStandardAssets.CinematicEffects.TonemappingColorGrading.BasicsSettings.contrast' cannot be accessed with an instance reference, qualify it with a type name ins$$anonymous$$d"

I have no idea what is happening.

avatar image Peaj · Jan 24, 2017 at 12:27 PM 0
Share

You should not change a Unity Standard Assets script and just make something static. If your own script is attached to the same Camera as the effect try using this: this.GetComponent< TonemappingColorGrading >().BasicsSettings.contrast = 0.5f;

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using a variable value with GetComponent 1 Answer

Accessing Scripts and Their Variables from other Objects 3 Answers

Calling variable accross scripts in C# problem (Closed) 1 Answer

variable scope problem 1 Answer

acces variables from other script 2 Answers


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