Skip to content

Instantly share code, notes, and snippets.

@EsProgram
Created August 31, 2014 16:07
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 EsProgram/b631b81c2bd997f726cb to your computer and use it in GitHub Desktop.
Save EsProgram/b631b81c2bd997f726cb to your computer and use it in GitHub Desktop.
Unity:allowAttachedObjectの条件を満たさないオブジェクトにはアタッチできないスクリプト
using System.Collections;
using UnityEngine;
public class DestroyMine : MonoBehaviour
{
private static GameObject allowAttachedObject;
private DestroyMine()
{
}
private void Awake()
{
allowAttachedObject = GameObject.FindGameObjectWithTag("Player");
}
private void Start()
{
if(allowAttachedObject != this.gameObject)
Destroy(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment