Skip to content

Instantly share code, notes, and snippets.

@atil
Created April 20, 2015 17:18
Show Gist options
  • Save atil/022bf87cb83fe3b36f6d to your computer and use it in GitHub Desktop.
Save atil/022bf87cb83fe3b36f6d to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public static class Utility
{
#region Rotation / Local Rotation
public static void SetRotation(this GameObject go, Quaternion rot)
{
go.transform.rotation = rot;
}
public static Quaternion GetRotation(this GameObject go)
{
return go.transform.rotation;
}
public static void SetLocalRotation(this GameObject go, Quaternion rot)
{
go.transform.localRotation = rot;
}
public static Quaternion GetLocalRotation(this GameObject go)
{
return go.transform.localRotation;
}
public static void SetRotation(this Component c, Quaternion rot)
{
c.transform.rotation = rot;
}
public static Quaternion GetRotation(this Component c)
{
return c.transform.rotation;
}
public static void SetLocalRotation(this Component c, Quaternion rot)
{
c.transform.localRotation = rot;
}
public static Quaternion GetLocalRotation(this Component c)
{
return c.transform.localRotation;
}
#endregion
#region Position
public static void SetPosition(this GameObject go, Vector3 pos)
{
go.transform.position = pos;
}
public static Vector3 GetPosition(this GameObject go)
{
return go.transform.position;
}
public static void SetPosition(this Component c, Vector3 pos)
{
c.transform.position = pos;
}
public static Vector3 GetPosition(this Component c)
{
return c.transform.position;
}
#endregion
#region Local position
public static void SetLocalPosition(this GameObject go, Vector3 pos)
{
go.transform.localPosition = pos;
}
public static Vector3 GetLocalPosition(this GameObject go)
{
return go.transform.localPosition;
}
public static void SetLocalPosition(this Component c, Vector3 pos)
{
c.transform.localPosition = pos;
}
public static Vector3 GetLocalPosition(this Component c)
{
return c.transform.localPosition;
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment