Global Game Jam 2021
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

57 lines
1.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParentBehaviour : MonoBehaviour
{
public spawner babySpawner;
public GameObject child;
public Texture baseVis;
public Texture hatVis;
public Texture eyeVis;
public Texture topVis;
public Texture bottomVis;
public List<string> order = new List<string>();
[ContextMenu("Get Random Child")]
public void GetRandomChild()
{
int _childIndex = Random.Range(0, babySpawner.transform.childCount);
child = babySpawner.transform.GetChild(_childIndex).gameObject;
//CHECK IF OTHER PARENT WANTS THIS CHILD (if otherParent.child == child)
Randomizer _childRandomizer = child.GetComponent<Randomizer>();
baseVis = _childRandomizer.baseObj.GetComponent<MeshRenderer>().material.mainTexture;
hatVis = _childRandomizer.hatObj.GetComponent<MeshRenderer>().material.mainTexture;
eyeVis = _childRandomizer.eyeObj.GetComponent<MeshRenderer>().material.mainTexture;
topVis = _childRandomizer.topObj.GetComponent<MeshRenderer>().material.mainTexture;
bottomVis = _childRandomizer.bottomObj.GetComponent<MeshRenderer>().material.mainTexture;
order.Insert(Random.Range(0, order.Count), "base");
order.Insert(Random.Range(0, order.Count), "hat");
order.Insert(Random.Range(0, order.Count), "eye");
order.Insert(Random.Range(0, order.Count), "top");
order.Insert(Random.Range(0, order.Count), "bottom");
foreach (string item in order)
{
print(item);
}
}
}