It’s mostly to reduce the amount of code I have to write:
public class MyObject : MonoBehaviour {
public static bool IsComputerBuild
{
get
{
#if UNITY_STANDALONE_OSX||UNITY_STANDALONE_PC||UNITY_WEBPLAYER||UNITY_EDITOR
return true;
#else
return false;
#endif
}
}
public virtual Vector3 LocalScale
{
get
{
return transform.localScale;
}
set
{
transform.localScale = value;
}
}
public virtual Vector3 Position
{
get
{
return transform.position;
}
set
{
transform.position = Position;
}
}
public virtual float PosX
{
set
{
Vector3 pos = transform.position;
pos.x = value;
transform.position = pos;
}
get
{
return transform.position.x;
}
}
public virtual float PosY
{
set
{
Vector3 pos = transform.position;
pos.y = value;
transform.position = pos;
}
get
{
return transform.position.y;
}
}
public virtual float PosZ
{
set
{
Vector3 pos = transform.position;
pos.z = value;
transform.position = pos;
}
get
{
return transform.position.z;
}
}
public virtual float RotZ
{
set
{
value = MyMath.Normalize(value, 0, 2 * Mathf.PI);
transform.rotation = Quaternion.AngleAxis(value * Mathf.Rad2Deg, new Vector3(0,0,1));
}
get
{
float rot;
Vector3 dir = new Vector3(0,0,1);
transform.rotation.ToAngleAxis(out rot, out dir);
return MyMath.Normalize(rot * Mathf.Deg2Rad, 0, 2*Mathf.PI);
}
}
public virtual float ScaleY
{
get
{
return transform.localScale.y;
}
set
{
Vector3 scale = transform.localScale;
scale.y = value;
transform.localScale = scale;
}
}
public virtual float ScaleX
{
get
{
return transform.localScale.x;
}
set
{
Vector3 scale = transform.localScale;
scale.x = value;
transform.localScale = scale;
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public static float PI
{
get
{
return Mathf.PI;
}
}
}