zoukankan      html  css  js  c++  java
  • 检测物体并互动

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class Interact
    {
    private Interact() { }
    public static class InteractInstance
    {
    public static Interact instance = new Interact();
    }
    public static Interact GetInstance()
    {
    return InteractInstance.instance;
    }

    public delegate void funtion(); //委托的方法

    public static Collider2D[] _collider2D; //检测到的物体
    public void Interacting(GameObject target, float radius, string colliderMask)
    {
    _collider2D = Physics2D.OverlapCircleAll(target.transform.position, radius, LayerMask.GetMask(colliderMask));
    if (_collider2D.Length > 0)
    {
    }
    else
    {
    }
    }
    public void Interacting(GameObject target, float radius, string colliderMask, funtion funtion1)
    {
    _collider2D = Physics2D.OverlapCircleAll(target.transform.position, radius, LayerMask.GetMask(colliderMask));
    if (_collider2D.Length > 0)
    {
    funtion1();
    }
    else
    {
    }
    }
    public void Interacting(GameObject target, float radius, string colliderMask, funtion funtion1, funtion funtion2)
    {
    _collider2D = Physics2D.OverlapCircleAll(target.transform.position, radius, LayerMask.GetMask(colliderMask));
    if (_collider2D.Length > 0)
    {
    funtion1();
    }
    else
    {
    funtion2();
    }
    }

    }

  • 相关阅读:
    负margin的原理及应用
    css display:flex 属性
    MapReduce api实战
    配置YARN高可用
    Yarn 分布式资源调度
    MapReduce 案例与概述
    HDFS 伪分布式集群搭建
    Hadoop的HA高可用实验
    Hadoop HDFS 集群的分布式搭建
    Zookeeper分布式协调服务
  • 原文地址:https://www.cnblogs.com/wei1349/p/14598980.html
Copyright © 2011-2022 走看看