Advertisement
DiasDouglas

Instanciar Cubo

Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class InstanciarCubo : MonoBehaviour
  7. {
  8.  
  9.     public Button botao;
  10.     public GameObject cubo;
  11.     public Transform cameraJogo;
  12.  
  13.     // Use this for initialization
  14.     void Start()
  15.     {
  16.         Button btn = botao.GetComponent<Button>();
  17.         btn.onClick.AddListener(instanciarBloco);
  18.     }
  19.  
  20.     // Update is called once per framed
  21.     void Update()
  22.     {
  23.  
  24.     }
  25.  
  26.     void instanciarBloco()
  27.     {
  28.         GameObject novoCubo = GameObject.Instantiate(cubo, cameraJogo.transform.position + cameraJogo.transform.forward*3, Quaternion.identity);
  29.         novoCubo.AddComponent<MoverAlgo>();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement