Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

Make child unaffected by parents rotation Unity

private float _rotation;
private Quaternion _originalRotation;
// set public to pass child reference in Unity Editor
public Canvas UIrotation;

    // Start is called before the first frame update
    void Start()
	{
    	// save child rotation values
  		_originalRotation = UIrotation.transform.rotation;
  		_rotation = transform.rotation.y;
	}

	private void OnMouseOver()
    {
    	// rotation of parent
        if (Input.GetKeyDown(KeyCode.Space))
        {
        	// parent rotate
            transform.Rotate(new Vector3(0, _rotation - 90, 0));
            // child rotate back to original without the need of update func 
            UIrotation.transform.rotation = _originalRotation;
        }
    }
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# check if username and password is true 
Csharp :: C# list of unique values with group and counts 
Csharp :: unity int inputfield value 
Csharp :: c# sha512 salt 
Csharp :: gridview edit update delete in asp.net textbox size 
Csharp :: Thread.Sleep() without freezing the UI 
Csharp :: two question marks c# 
Csharp :: mouse position to canvas transform 
Csharp :: initialization of dictionary in other forms c# 
Csharp :: soundplayer c# take uri 
Csharp :: jtoken value is not exact double 
Csharp :: c# ulong 
Csharp :: hacker 
Csharp :: add buttons to taskbar thumbnail WPF 
Csharp :: radio buttons into database stackoverflow 
Csharp :: c# sort word 
Csharp :: dfgf 
Csharp :: Program to find GCD or HCF of two numbers c# 
Csharp :: how to mock abstract httpcontext using moq .net core 
Csharp :: c# changimg to one decimal place 
Csharp :: why process not found in c# 
Csharp :: c# string to control name 
Csharp :: .net entities query multiple join condition 
Csharp :: screenshot c# WinForms 
Csharp :: unity gamemanager instance not set to an instance of an object 
Csharp :: Acrylic UWP Title bar C# 
Csharp :: unity remove component 
Csharp :: bitwise and c# 
Csharp :: array in unity 
Csharp :: how to convert c# string to pdf 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =