Hi
I have a circular shape that I created in Blender which I have called Lane. In my code I also have a class LaneInfo which holds some properties for the Lane gameobject. In Unity I have then dragged the Lane object into the prefab folder.
In my code I want to instantiate multiple instances of this prefab with each one scaled differently. This is in order to form concentric rings around a common centre.
When I test the game the scaling seem to look fine, but when I go back to the prefab and check the Transform in the inspector the scale of the prefab has been changed to reflect the last scale values of the clones. I would like to keep the transform values of the original prefab constant while only manipulating the transform values of the clones. Can this be done?
I am using the following code:
//List of LaneInfo objects. Each LaneInfo object holds info about width, color of lane
private List<LaneInfo> resourceLaneInfos;
public Transform laneTransform;
public void SetupGameBoard()
{
float scaleValue = 1.0f;
foreach (LaneInfo lane in resourceLaneInfos)
{
Instantiate(laneTransform, new Vector3 (), Quaternion.identity);
laneTransform.localScale = new Vector3 (1.0f * scaleValue, 1.0f, 1.0f * scaleValue);
scaleValue += 0.2f;
}
}
Kind regards.
Kobus