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 /
  • 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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

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

GetPixel returning #FFFFFF (works properly in Player, breaks on Android) 1 Answer

ScreenToWorldPoint() not working properly using a RenderTexture 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