Unity3D Rotate only image in button - button

I'm looking for a way to rotate the image of a button without rotating the text.
I tried to fix the rotation of the text like this :
transform.eulerAngles = new Vector3(transform.eulerAngles.x, transform.eulerAngles.y, camera.transform.eulerAngles.y + 90); // Rotation of the whole button
GetComponentInChildren<Text>().transform.localEulerAngles = Vector3.zero; // Lock rotation of the text
... and it works but the problem is that the text position is moving with the image, like it's fix to it.
I searched on internet but didn't find the same case.
Thanks for help !

Since your text is a child of the button GameObject you are rotating, it will be affected as well. Instead of trying to reflect the rotation you should make the image a child of the button and only rotate that Transform.
button `GameObject`
— image (rotate this)
— text `Text`

Related

How to make a round WKInterfaceButton in watchkit?

iOS can use layer.cornerRadius to make a round UIButton.
Does WKInterfaceButton have this property?
If not, how can I make a round WKInterfaceButton in WatchKit.
If you put an image inside a group, you can then set the radius of the group. This crops the image into a circle. In the picture below, I have:
Group (radius 56)
Group (radius 52)
Image (a square image)
While this example is with an image, you can use the same technique for a button. Previously the dog was clickable as a button so this is doable.
WKInterfaceButton does not have a corner radius property. You can make a circular button by setting a circular image as the button's background image. You can generate the image in code doing something like this: Draw a simple circle uiimage
You don't need an image to make WKInterfaceButton rounded. Instead:
Go to Attributes inspector for the button, and select content type: Group
Inside the button find the group and set its corner radius to whatever you need.
Scroll down the inspector and set both fixed Width and Height to the value equal to the radius doubled. Here you go
You can put whatever you want inside the button, for example a text label. This way you also can make oval buttons.

Rotating image animation in fxml

I am having a custom image, i just need to rotate the image while loading the respective page instead of default indeterminate progress indicator symbol. Do we have any css code to rotate the image continuously. please guide me.
You don't use css to rotate things in JavaFX 8, use a RotateTransition:
RotateTransition rt = new RotateTransition(Duration.millis(3000), imageView);
rt.setByAngle(360);
rt.setCycleCount(Animation.INDEFINITE);
rt.setInterpolator(Interpolator.LINEAR);
rt.play();

-webkit-transform: rotate - hides elements on top

I'm using -webkit-transform: rotate(40 deg) and it seems that the rotated element is hiding parts of elements which are on top ( not children ) of the rotated one.
I created a jsFiddle here with the code, since it will be easier to demonstrate.
Probably this is because the rotated element hides parts of other elements, but I don't want this effect. How can I fix that?
I used z-index but it doesn't help!
You're doing a 3D transform. You have 'rotateY' in the fiddle not 'rotate'.
So you're moving part of the plane in front of the buttons.
Check for yourself by changing code for the second button to
$("div.buttonB").click( function() {
$("div.background").css('-webkit-transform', 'rotateY(-190deg)')
});
​This way after clicking buttonB, buttonB will be clickable but buttonA won't.
Now change -190deg to 190deg and you'll see that it works other way around.
If you want to wrap your head around 3D transformations check out this site.
http://thewebrocks.com/demos/3D-css-tester/
Watch the video and play with the controls. Hope this helps.

QT pixel position from image when mouse click

I'm using QGraphicView and QGraphicScene to display and image. I would like to get image pixel coordinate when i mouse click on that pixel. For that i use mousePressEvent and implement function to isplay event position. But the problem is the image pixel position is wrong because i obtain the pixel coordinate corresponding to the GraphicView not the pixel coordinate in the image. I think it will gives me a right answer when the view have exactly the same size than the image (at least how to do that ?), but i preffer more sophisticated solution.
Please help
You override the mouse press event for QGraphicsPixmap item.

How to create a button on our desire shape like circle, star in flex 3?

I would like to customize the shape of the button to different shapes like circle, star, square or of any shape. How would i achieve so?
I apologize because this doesn't answer your question, but:
In order to make sure the user can reliably click on your button, you probably want it to be a convex shape. A rectangle or circle is fine, and you could paint a star on it. But you wouldn't want the user to try to click your star and miss, just because they were not quite inside one of its arms.
Canvas can be used as button.
Take a canvas of required size. Give your required button shape(image) as background image to canvas.
Example:
Explanation: {nextYellowButton} is the embedded button. It is an arrow mark shape button.
It is a .PNG image. So, it doesn't include the background color.
Now your button is of arrow shape. it occupies 50px * 50px area on screen. But it looks exactly like an arrow mark.

Resources