Advertisement
Guest User

Instantiate

a guest
Jan 21st, 2018
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. using UnityEditor;
  7. public class ImageCouch : MonoBehaviour, IPointerClickHandler {
  8.   public GameObject target;
  9.   public float speedtrans = 0.2f;
  10.   public float moveSpeed = 10f;
  11.   public float turnSpeed = 50f;
  12.   private GameObject instance;
  13.   private bool clickado = false;
  14.   private bool true_delete = false;
  15.  
  16.   public void OnPointerClick(PointerEventData eventData)
  17.   {
  18.     instance = Instantiate(Resources.Load("Couch_1", typeof(GameObject))) as GameObject;
  19.     instance.transform.parent = target.transform;
  20.     instance.transform.localScale += new Vector3(30F, 30F, 30F);
  21.     instance.transform.localPosition = new Vector3(0, 0, 0);
  22.     clickado = true;
  23.  
  24.   }
  25.  
  26.   // Use this for initialization
  27.   void Start () {
  28.        
  29.     }
  30.    
  31.     // Update is called once per frame
  32.     void Update () {
  33.    
  34.   }
  35.  
  36.   void OnGUI()
  37.   {
  38.     if (clickado == true)
  39.     {
  40.       if (GUILayout.Button("Del Couch"))
  41.       {
  42.         true_delete = true;
  43.       }
  44.       if (true_delete)
  45.       {
  46.         DestroyObject(instance);
  47.         clickado = false;
  48.         true_delete = false;
  49.       }
  50.  
  51.     }
  52.  
  53.  
  54.   }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement