Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public GameObject virus1; // Prefab
- //public GameObject panel; // Panel
- public void Destroy()
- {
- Destroy(gameObject);
- Instantiate (virus1, new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f), Quaternion.identity); // деапозон спавна
- // GameObject childObject = Instantiate (virus1, new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f), Quaternion.identity); // деапозон спавна
- // childObject.transform.SetParent(panel.transform, false); // родитель
- }
- SomeButton.transform.SetParent(panel.transform, false);
- public GameObject virus1; // Prefab //проследи что бы был заасайнен префаб
- private GameObject panel; // Panel
- // Use this for initialization
- void Start()
- {
- panel = GameObject.Find("panelr");//проследи что бы это имя было ПРАВИЛЬНО указано
- }
- public void Destroy()
- {
- GameObject childObject = Instantiate (virus1, new Vector3(0f, 0f, 0f), Quaternion.identity);
- childObject.transform.SetParent(panel.transform, false);
- childObject.transform.position = new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f);//парент уже задан и теперь уже нужно задавать позицию, ПОСЛЕ того как задан парент
- Destroy(gameObject);
- }
- public GameObject virus1; // Prefab
- private GameObject panel; // Panel
- // Use this for initialization
- void Start()
- {
- panel = GameObject.Find("VirusEvolution"); // Panel которая является родителем
- }
- public void Evolution()
- {
- GameObject childObject = Instantiate(virus1, new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f), Quaternion.identity); // деапозон спавна
- childObject.transform.SetParent(panel.transform, false);
- Destroy(gameObject); // удаление virus
- }
Add Comment
Please, Sign In to add comment