How would i go around making a “new” standard transform.
Atm it looks like 123, 245, 886 in the editor. How would i do so unity make the funky number the standard “1,1,1”.
How would i go around making a “new” standard transform.
Atm it looks like 123, 245, 886 in the editor. How would i do so unity make the funky number the standard “1,1,1”.
For what purpose?
Build a static method like
class weirdtransform {
public static transform( t : Transform ) : Transform {
var x : Transform;
x.rotation = t.rotation;
x.position = t.position - Vector3(123,456,886);
return x;
}
}
And then never use transform calls directly from code again, instead of gameObject.Transform.anything, use weirdtransform.transform( gameObject.Transform ).anything
That said, you may want to rethink what you're doing. 1,1,1 is a very nice central location.
Hey i want to normalize the transformer when looking in the unity editor.
This is my solution.
public abstract class CustomComponent : Component
{
public new CustomTransform transform;
}
public class CustomTransform
{
public Vector3 position
{
get
{
initialize_transform();
return transform_reference.position;
}
set
{
initialize_transform();
transform_reference.position = value;
transform_reference.position.Normalize();
}
}
private void initialize_transform()
{
if (transform_reference == null)
{
transform_reference = this.GetComponent<Transform>();
}
}
Transform transform_reference;
}
This strategy can be done with any class with Transform transform
, but bear in mind that 1) You still have to change the Transform
in CustomTransform
and 2) Using a reference to the Component
(rather than CustomComponent
) will alter Transform
(not CustomTransform
).