Quantcast
Viewing latest article 29
Browse Latest Browse All 90

Answer by Matt-Downey

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_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`).

Viewing latest article 29
Browse Latest Browse All 90

Trending Articles