Guest User

Untitled

a guest
Nov 15th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. public GameObject virus1; // Prefab
  2. //public GameObject panel; // Panel
  3.  
  4. public void Destroy()
  5. {
  6. Destroy(gameObject);
  7. Instantiate (virus1, new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f), Quaternion.identity); // деапозон спавна
  8. // GameObject childObject = Instantiate (virus1, new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f), Quaternion.identity); // деапозон спавна
  9. // childObject.transform.SetParent(panel.transform, false); // родитель
  10. }
  11.  
  12. SomeButton.transform.SetParent(panel.transform, false);
  13.  
  14. public GameObject virus1; // Prefab //проследи что бы был заасайнен префаб
  15. private GameObject panel; // Panel
  16.  
  17. // Use this for initialization
  18. void Start()
  19. {
  20. panel = GameObject.Find("panelr");//проследи что бы это имя было ПРАВИЛЬНО указано
  21. }
  22.  
  23. public void Destroy()
  24. {
  25. GameObject childObject = Instantiate (virus1, new Vector3(0f, 0f, 0f), Quaternion.identity);
  26.  
  27. childObject.transform.SetParent(panel.transform, false);
  28.  
  29. childObject.transform.position = new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f);//парент уже задан и теперь уже нужно задавать позицию, ПОСЛЕ того как задан парент
  30.  
  31. Destroy(gameObject);
  32. }
  33.  
  34. public GameObject virus1; // Prefab
  35. private GameObject panel; // Panel
  36.  
  37. // Use this for initialization
  38. void Start()
  39. {
  40. panel = GameObject.Find("VirusEvolution"); // Panel которая является родителем
  41. }
  42.  
  43. public void Evolution()
  44. {
  45. GameObject childObject = Instantiate(virus1, new Vector3(Random.Range(-300f, 300f), Random.Range(-600f, 600f), 0f), Quaternion.identity); // деапозон спавна
  46. childObject.transform.SetParent(panel.transform, false);
  47. Destroy(gameObject); // удаление virus
  48. }
Add Comment
Please, Sign In to add comment