Skip to content

Instantly share code, notes, and snippets.

@TheStoneBook
Last active July 6, 2018 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheStoneBook/5c760beac554f0718c637ff7be2d4574 to your computer and use it in GitHub Desktop.
Save TheStoneBook/5c760beac554f0718c637ff7be2d4574 to your computer and use it in GitHub Desktop.
【Unity】Bounds.Containsのテスト
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class BoundsContainsTest : MonoBehaviour,IDragHandler {
[SerializeField]
private GameObject EnteredObject;
public void OnDrag(PointerEventData data){
Vector3 TargetPos = Camera.main.ScreenToWorldPoint (data.position);
TargetPos.z = 0;
transform.position = TargetPos;
Bounds _bounds = EnteredObject.GetComponent<Collider2D> ().bounds;
if (_bounds.Contains (gameObject.transform.position))
{
Debug.Log ("重なってるよー!");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment