/// <summary> /// Drop a 3D game object onto the surface. /// </summary> protected override void OnDragDropRelease(GameObject surface) { if (surface != null) { ExampleDragDropSurface dds = surface.GetComponent <ExampleDragDropSurface>(); if (dds != null) { GameObject child = NGUITools.AddChild(dds.gameObject, prefab); Transform trans = child.transform; trans.position = UICamera.lastHit.point; if (dds.rotatePlacedObject) { trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); } // Destroy this icon as it's no longer needed NGUITools.Destroy(gameObject); return; } } base.OnDragDropRelease(surface); }
/// <summary> /// Drop a 3D game object onto the surface. /// </summary> protected override void OnDragDropRelease(GameObject surface) { //in this method, the player is releasing the draggable object //the inherited boolean from UIDragDropItem placeATower = true; //spawn a tower if it is a valid place for one towerSpawner.GetComponent <TowerSpawnerScript>().spawnTower(towerType); if (surface != null) { ExampleDragDropSurface dds = surface.GetComponent <ExampleDragDropSurface>(); if (dds != null) { GameObject child = NGUITools.AddChild(dds.gameObject, prefab); child.transform.localScale = dds.transform.localScale; Transform trans = child.transform; trans.position = UICamera.lastWorldPosition; if (dds.rotatePlacedObject) { trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); } // Destroy this icon as it's no longer needed NGUITools.Destroy(gameObject); return; } } base.OnDragDropRelease(surface); }
/// <summary> /// Drop a 3D game object onto the surface. /// </summary> //overriding the release of a drag and drop object protected override void OnDragDropRelease(GameObject surface) { //in this method, the player is releasing the draggable object, so we call the spawnHuman method and pass it the type of //human that the player was dragging humanSpawner.GetComponent <HumanSpawnerScript>().spawnHuman(humanType); if (surface != null) { ExampleDragDropSurface dds = surface.GetComponent <ExampleDragDropSurface>(); //not Bassel Bitar's code. Ignore this if block if (dds != null) { GameObject child = NGUITools.AddChild(dds.gameObject, prefab); child.transform.localScale = dds.transform.localScale; Transform trans = child.transform; trans.position = UICamera.lastWorldPosition; if (dds.rotatePlacedObject) { trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); } // Destroy this icon as it's no longer needed NGUITools.Destroy(gameObject); return; } } base.OnDragDropRelease(surface); }
/// <summary> /// Drop a 3D game object onto the surface. /// </summary> protected override void OnDragDropRelease(GameObject surface) { // Re-enable the collider if (mButton != null) { mButton.isEnabled = true; } else if (mCollider != null) { mCollider.enabled = true; } else if (mCollider2D != null) { mCollider2D.enabled = true; } if (surface != null) { ExampleDragDropSurface dds = surface.GetComponent <ExampleDragDropSurface>(); if (dds != null) { cloneOnDrag = false; //GameObject child = NGUITools.AddChild(dds.gameObject, prefab); //child.transform.localScale = dds.transform.localScale; //Transform trans = child.transform; //trans.position = UICamera.lastWorldPosition; //if (dds.rotatePlacedObject) //{ // trans.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); //} base.restriction = Restriction.None; // Destroy this icon as it's no longer needed //NGUITools.Destroy(gameObject); return; } } NGUITools.Destroy(gameObject); //base.OnDragDropRelease(surface); }
protected override void OnDragDropRelease(GameObject surface) { if (surface != null) { ExampleDragDropSurface component = surface.GetComponent <ExampleDragDropSurface>(); if (component != null) { GameObject gameObject = NGUITools.AddChild(component.gameObject, this.prefab); gameObject.transform.localScale = component.transform.localScale; Transform transform = gameObject.transform; transform.position = UICamera.lastWorldPosition; if (component.rotatePlacedObject) { transform.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); } NGUITools.Destroy(base.gameObject); return; } } base.OnDragDropRelease(surface); }
protected override void OnDragDropRelease(GameObject surface) { if (surface != null) { ExampleDragDropSurface component = surface.GetComponent <ExampleDragDropSurface>(); if (component != null) { GameObject gameObject = NGUITools.AddChild(component.gameObject, this.prefab); gameObject.transform.localScale = component.transform.localScale; Transform transform = gameObject.transform; transform.position = UICamera.lastHit.point; if (component.rotatePlacedObject) { transform.rotation = Quaternion.LookRotation(UICamera.lastHit.normal) * Quaternion.Euler(90f, 0f, 0f); } NGUITools.Destroy(base.gameObject); Singleton <PvpRoomView> .Instance.IsLock = false; return; } } if (!this.cloneOnDrag) { this.mTouchID = -2147483648; if (this.mCollider != null) { this.mCollider.enabled = true; } UIDragDropContainer uIDragDropContainer = (!surface) ? null : NGUITools.FindInParents <UIDragDropContainer>(surface); if (uIDragDropContainer != null) { this.mTrans.parent = ((!(uIDragDropContainer.reparentTarget != null)) ? uIDragDropContainer.transform : uIDragDropContainer.reparentTarget); Vector3 localPosition = this.mTrans.localPosition; localPosition.z = 0f; this.mTrans.localPosition = localPosition; } else { this.mTrans.parent = this.mParent; } this.mParent = this.mTrans.parent; this.mGrid = NGUITools.FindInParents <UIGrid>(this.mParent); this.mTable = NGUITools.FindInParents <UITable>(this.mParent); if (this.mDragScrollView != null) { this.mDragScrollView.enabled = true; } NGUITools.MarkParentAsChanged(base.gameObject); if (this.mTable != null) { this.mTable.repositionNow = true; } if (this.mGrid != null) { this.mGrid.repositionNow = true; } } else { Singleton <PvpRoomView> .Instance.ReplaceMatchPosition(base.GetComponent <MatchItem>()); NGUITools.Destroy(base.gameObject); } Singleton <PvpRoomView> .Instance.IsLock = false; AudioMgr.PlayUI("Play_UI_Page", null, false, false); }