Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by Wolfram · Feb 16, 2010 at 02:32 PM · editorinspectorcolor

How to assign a color shown in the "Color" window to a color field in the inspector?

When I click on a color in the inspector, the "Color" window opens, showing the corresponding color. How can I assign/copy this color value to a different color field in the inspector, another material, etc.? Or if that isn't possible, how to copy color settings directly from component A to component B?

I didn't find any context menus for this, no drag&drop, or similar. The pipette next to the color shown in the inspector doesn't seem to do anything, either (what's it for?)

Thanks, Wolfram

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

6 Replies

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

Answer by duck · Feb 16, 2010 at 04:28 PM

The only way I've found to do this is to manually copy the R,G,B (or H,S,B) values across - either by remembering the 3 values while switching to the destination colour, or by noting down the values in notepad or something. Not ideal at all, but it's one of those things that I've gotten so used to doing (in many other apps too, not just unity) that I didn't even notice it was a missing feature.

In fact, now you mention it, I don't ever recall seeing an app where you can copy and paste colour values!

Comment
Add comment · Show 1 · 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 Wolfram · Feb 25, 2010 at 03:13 PM 0
Share

this doesn't solve my problem, but it answers the question ;-)

avatar image
2
Best Answer

Answer by Statement · Feb 16, 2010 at 04:30 PM

Unfortunately you can't change Color fields while editing AFAIK. If you do try that, then changing color does not have any effect on the new selection. You have to create your custom code for copying colors from one field to another. One way to do this would be an editor script. If you do some magic with reflection to find all the color fields on a selected target A, and all the color fields on a selected target B, then you could write code that copies color (or any variable) from A.a to B.b if you get my drift.

System.Reflection contains classes you'd want to use for this purpose. Basically you should find all field member of a selected object, and for all member field who has a field type of Color, you should display in a list. FieldInfo is the class you want to use for accessing and manipulating data, and it should be available from the objects Type (someObject.GetType()).

When you want to get some value from a field with reflection, you basically call someFieldInfo.GetValue(someObject); where someObject is the object you want to get the field data from. Likewise, someFieldInfo.SetValue(someObject, value) sets value to the field on someObject. GetValue returns a variable type of object, so you have to cast it to the expected type before you work with it.

Actually, this sounds like a good add-on, and I might get around making a general-purpose variable copier. I would be happy to share it with all of you, but if you want it now then its best you roll your own code because I have a lot on my hands these days.

Reflection might sound scary to some people, but it is just about enumerating the members of some type, then through that member you can call/read/write stuff. Type, FieldInfo and BindingFlags should be the only "strange" classes you should have to work with.


There might exist other more simple solutions to this problem, and if you find a simple solution, always go for the simplest solution.

I hope you find a solution to your problem.

Comment
Add comment · Show 1 · 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 Wolfram · Feb 25, 2010 at 03:19 PM 0
Share

Unfortunately, I know nothing about program$$anonymous$$g the editor, and dont't have the time to learn it. :-/

avatar image
2

Answer by getluky · Apr 25, 2012 at 11:06 PM

Ah, I recently discovered a bit of a hacky way to do this quickly. It relies upon the fact that you can have multiple inspector tabs open at once, and lock them onto a single target.

1) select the GameObject you want to copy a color from. Lock its inspector.

2) click on the options widget (upper-right hand corner) on a separate window area (such as project folder window) and select Add Tab > Inspector.

3) select the GameObject you want to copy the color to. Observe that you have one inspector for target and one inspector for source now.

4) Click the pipette on the target color swatch and mouse-over then click on the color swatch area from the source color. Your color is "copied" directly.

5) Repeat with new target GameObjects as necessary.

It's not as quick as CTRL-C, CTRL-V, but it gets the job done quite quickly for me. Hope that helps!

Comment
Add comment · Show 3 · 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 Unislash · Aug 10, 2012 at 05:41 AM 0
Share

This is the best answer for windows users. It is a little clunky, but it works.

avatar image s_guy · Jun 24, 2013 at 09:52 PM 0
Share

I stumbled on this too. Works pretty well, but you still have to set alpha manually. Is that conventional for pipette functionality?

avatar image Unislash · Jun 25, 2013 at 03:28 AM 0
Share

In my experience pipettes don't grab the alpha, but rather the rendered color

avatar image
1

Answer by Ashkan_gc · Feb 16, 2010 at 04:10 PM

when you change the color it will change that property after you close the window. then you can get that color property and assign it to others. use the selection class and get the property that you want. for example

Color c = Selection.ActiveGameObject.renderer.material.color;

then you can copy c to any other color property.

Comment
Add comment · Show 1 · 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 Wolfram · Feb 25, 2010 at 03:18 PM 0
Share

Hm, since I know nothing about program$$anonymous$$g the editor, I cannot really make use of this. How would a function look like, that actually copies color components from one component to another?

avatar image
1

Answer by Eric5h5 · Feb 16, 2010 at 08:21 PM

If you're using OS X, you have the option in the Unity preferences to use the OS X color picker. This is quite a bit more robust than the Unity color picker, and has among other things the option of creating your own color lists and swatches, which basically amounts to being able to copy and paste colors.

As far as the pipette next to the color, it allows you to pick a color from any pixel you move the cursor over. This can be anywhere on the screen, not just the Unity window, so you could potentially create color swatches and use the pipette to pick from them.

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 Wolfram · Feb 17, 2010 at 01:59 PM 0
Share

Unfortunately, we're stuck with Windoze here.

What you describe for the pipette is the pipette inside the color window. I meant the one in the Inspector, next to any color field.

avatar image Eric5h5 · Feb 17, 2010 at 04:55 PM 0
Share

Actually that's what I mean too, unless that works differently in the Windows version of Unity (which would probably be a bug, because it really shouldn't).

avatar image Wolfram · Feb 25, 2010 at 12:03 PM 0
Share

Ah, ok, it's a bug then. I just checked it on a $$anonymous$$ac, and it works as you describe.

avatar image Wolfram · Feb 25, 2010 at 03:20 PM 0
Share

Just submitted a bug report for that.

avatar image yoyo · Oct 19, 2010 at 04:25 PM 0
Share

The pipette is really handy, I use it all the time.

Show more comments
  • 1
  • 2
  • ›

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

2 People are following this question.

avatar image avatar image

Related Questions

Is there a way to get Editor background color? 4 Answers

Inspector Popup format to look like tag or layer popup 1 Answer

Custom color for properties in Inspector. 1 Answer

Repurposing the inspector graph module 2 Answers

How could I merge 2 components' inspectors through a custom editor? 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