Layering images and moving them within an Editor Window... is it possible?
I'm putting together some custom Editor Windows and want to recreate a tool similar to this from RPG Maker:
This tool is for setting up Mobs in battle. You add enemies to the picture then can drag the individual enemies around to position them.
I know how to use EditorGUI.DrawPreviewTexture but is it possible to layer the image and then detect it's X and Y position of the monster's image within the background image?
My first thought is to update the Image Rect in OnGUI... but I'd need to detect mouse down and if it's on an enemy image... I'm going to experiment with that idea, but any help would be appreciated.
Answer by Optimus_L · Nov 24, 2021 at 05:08 AM
Think I've figured it out.
So been playing around and yes you can layer images... although my transparent PNG is coming through as black. Not sure if this is because of the layering or because of how I'm getting the Texture... but yeah, I think I've worked out enough to get this working.
If anyone is interested, I used DrawPreviewTexture, and draw the background first, then I go through each enemy in the mob and draw them.
Then using Event.current.mousePosition, I can get the mouse position and mouseDown Event Type.
I've been able to detect if an enemy has been selected, and I can update the position of the enemy. Rest should be straight forward. Just need to sort out those black backgrounds...
Your answer
Follow this Question
Related Questions
Do Unity Editor GUI Utilities (Handles.DrawLine & EditorGUI.DrawRect) have limitations? 2 Answers
Can't update ObjectField after object is selected 1 Answer
How to Have a ReoderableList in a Custom Editor Window 1 Answer
How to change the text of EditorGUILayout.TextField 2 Answers
Editor Int sliders affecting each other 0 Answers