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!