• 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 /
  • Help Room /
avatar image
0
Question by jpswital · Feb 09, 2016 at 03:02 PM · colorrendertexturepixelpasscolorpicker

Capture Mouse position color of pixel from current frame of Movie Texture

Thank you for taking the time to read. I understand there are many pieces to accomplish what I am asking and I don't want to derail a better way with my noob attempts. I will explain where I am at and where I am stuck however below.

What I am try to do: I have two movie textures, Raw Images, playing on a Canvas.
Movie 1 is a normal cutscene. Movie 2 has a single color hitbox which tracks with the characters in Movie 1. *Note: Movie 2 also has a a shader to make it properly display the hitbox on top of Movie 1.
When the mouse is clicked I want to detect if the hitbox area was clicked.

My current thought is to check if the pixel color that was hit matches the hitbox color of the movie. I think I can output this pixel color by rendering a Texture Image on mouse click and pass it to the script below (leveraged from Sreejit Pillai on another site)

public Texture2D ColorPalleteImage; //Any Texture Image public Color ColorBelowMousePointer; public Rect ColorPanelWidthAndHeight; // set width and height appropriately

void OnGUI() { GUI.DrawTexture(ColorPanelWidthAndHeight, ColorPalleteImage);

 if (GUI.RepeatButton(ColorPanelWidthAndHeight, ColorPalleteImage))
 {
     Vector2 pickpos  = Event.current.mousePosition;

     float aaa  = pickpos.x - ColorPanelWidthAndHeight.x;

     float bbb  =  pickpos.y - ColorPanelWidthAndHeight.y;

     int aaa2  = (int)(aaa * (ColorPalleteImage.width / (ColorPanelWidthAndHeight.width + 0.0f)));

     int bbb2  =  (int)((ColorPanelWidthAndHeight.height - bbb) * (ColorPalleteImage.height / (ColorPanelWidthAndHeight.height + 0.0f)));

     Color col  = ColorPalleteImage.GetPixel(aaa2, bbb2);

     ColorBelowMousePointer= col;
     Debug.Log(ColorBelowMousePointer);
 }

}

I am very new to Unity and I might be completely off my rocker. Any help is greatly appreciated! Thanks!

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

0 Replies

· Add your reply
  • Sort: 

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Wrong Coloring (Sometimes) when capturing "Screen"-shot 1 Answer

Pick Color From Image - Unity UI 0 Answers

Get pixelvalues from video clip 0 Answers

How to get the color under the player's current location?,How to get the color under the location where the player is standing? 0 Answers

Get colour of a pixel on a texture? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges