public void OnAdd(DragableObject objectToAdd) { OnRemove(); GameObject draggedObj = Instantiate(objectToAdd.gameObject, transform.position, transform.rotation, transform.parent); draggedObj.GetComponent <RectTransform>().sizeDelta = new Vector2(100, 100); contained = draggedObj.GetComponent <DragableObject>(); contained.dragged = false; contained.transform.SetSiblingIndex(0); //Unlock for (int i = 0; i < followingSquares.Count; i++) { if (followingSquares[i].locked) { followingSquares[i].Unlock(); } else { break; } } //Lock for (int i = 0; i < Mathf.Min(followingSquares.Count, contained.size - 1); i++) { followingSquares[i].Lock(); if (followingSquares[i].contained != null) { Destroy(followingSquares[i].contained.gameObject); } } Image[] imagesDragged = contained.GetComponentsInChildren <Image>(); for (int i = 0; i < imagesDragged.Length; i++) { imagesDragged[i].raycastTarget = false; } OnPointerExit(null); CharacterBehaviourManager.instance.AddBehaviour(contained.action); }
public void OnBeginDrag(PointerEventData eventData) { if (Input.GetMouseButton(2)) { return; } GameObject draggedObj = Instantiate(gameObject, transform.position, transform.rotation, transform.parent); DragableObject dra = draggedObj.GetComponent <DragableObject>(); dra.dragged = true; Image[] imagesDragged = dra.GetComponentsInChildren <Image>(); for (int i = 0; i < imagesDragged.Length; i++) { imagesDragged[i].raycastTarget = false; } MemoryBarManager.instance.dragedObject = dra; }