As a part of some basic code I’m writing, I make a copy of a prefab as a member of a list. I then edit the localScale of the object in the list. When I do this however, the scale of the object changes in my assets windows and persists after the game stops running. Here is my code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class CreatePlatforms : MonoBehaviour
{
public GameObject platformPrefab;
private int numToMake;
private List<GameObject> platforms = new List<GameObject>();
// Use this for initialization
void Start ()
{
numToMake = 2;
Create();
}
// Update is called once per frame
void Update ()
{
}
void Create()
{
for(int i = 0; i < numToMake; i++)
{
platforms.Add(platformPrefab);
platforms*.transform.localScale /= numToMake;*
Instantiate(platforms_, new Vector3(1.2f + numToMake1.2f, .85f + numToMake.85f, 0), Quaternion.identity);_
* }*
* }*
}
The “platformPrefab” is attached to my script through the editor.
I also realize the math on my Instantiate command won’t do what I want for a variety of reasons, but the localScale problem is more an issue to me at the moment.