I have a button that has a image inside it as a child. When you click the button, the child image follows your mouse cursor. the image following the mouse is later destroyed on click. I need to add a new image to the button. How do you add a child object in my case a new image to the button as a child? It needs to basically be a copy of the image originally inside the button.
Why not just clone the image that is used to follow and turn off the one on the button? Or have a floating image that gets turned on and copies the sprite and that one follows the cursor?
No, don't really have sample code. You have a button with an image gameobject as a child. You have a floating image gameobject. Click on the button, copy the sprite from the child image component to the floating image component. Turn off the child. Turn on a floating image gameobject. The floating object should follow your cursor. When it's clicked on, turn off the floating object, turn on the child object which will have it's original sprite. Or if you need to, change it's sprite to whatever. If I misunderstood what you are trying to accomplish, please expand on your question.