- Home /
create a primitive plane with specific size with unity
Hi, i have a problem
How can I create a primitive plane in unity3D C# with specific size?
I am trying with this code:
GameObject plane = GameObject.CreatePrimitive (PrimitiveType.Plane); GameObject augmentation = (GameObject)GameObject.Instantiate (plane); augmentation.transform.parent = plane.transform; augmentation.transform.localPosition = new Vector3 (0f, 0f, 0f); augmentation.transform.localRotation = Quaternion.identity; augmentation.transform.localScale = new Vector3 (0.005f, 0.005f, 0.005f); augmentation.gameObject.SetActive (true);
When the app is running on android shows a plane of size 10 x 10.
Answer by SolomonG · Jul 05, 2017 at 05:30 PM
With your code on my system, the plane augmentation
is being created with the proper size. However, the plane plane
is being instantiated at the same position but with the default scaling (1x1). This is concealing augmentation
and making it appear to be 1x1 instead of 0.005x0.005. Are you sure that the plane is appearing as 10x10 and not 1x1? I'd either hide the parent plane ( plane
) with plane.GetComponent<MeshRenderer>().enabled = false
, or differentiate augmentation
somehow (set different y-position and material).