1
0
This repository has been archived on 2024-09-03. You can view files and clone it, but cannot push or open issues or pull requests.
System-Purge/Assets/Resources/Scripts/Platform.cs
2016-01-30 02:38:33 -05:00

45 lines
1.4 KiB
C#

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[ExecuteInEditMode]
public class Platform : MonoBehaviour
{
public Sprite sprite;
public int addNum;
public GameObject prefab;
public bool isParent = true;
int oldNum = 0;
// Update is called once per frame
void Update ()
{
//Updates all of the children's SpriteRender sprites
foreach (SpriteRenderer i in GetComponentsInChildren<SpriteRenderer>())
{
i.sprite = sprite;
}
/*Vector3 curPos = this.transform.position;
float scaleX = this.transform.lossyScale.x;
if (this.gameObject.transform.childCount < addNum && !Application.isPlaying && isParent)
{
for (int i = 0; i < addNum - oldNum; i++)
{
curPos = curPos + new Vector3(scaleX, 0);
GameObject childObj = Instantiate(prefab, curPos, Quaternion.identity) as GameObject;
childObj.GetComponent<Platform>().isParent = false;
childObj.transform.parent = transform;
curPos = childObj.transform.position;
transform.GetChild(transform.childCount);
}
for (int i = 0; i < oldNum - addNum; i++)
{
Destroy(transform.GetChild(transform.childCount));
}
oldNum = addNum;
}*/
}
}