Exemple #1
0
        public static WaterVolumeProbe CreateProbe(Transform target, float size = 0f)
        {
            GameObject gameObject = new GameObject("Water Volume Probe")
            {
                hideFlags = HideFlags.HideAndDontSave
            };

            gameObject.transform.position = target.position;
            gameObject.layer = WaterProjectSettings.Instance.WaterCollidersLayer;
            SphereCollider sphereCollider = gameObject.AddComponent <SphereCollider>();

            sphereCollider.radius    = size;
            sphereCollider.isTrigger = true;
            Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();

            rigidbody.isKinematic = true;
            rigidbody.mass        = 1E-07f;
            WaterVolumeProbe waterVolumeProbe = gameObject.AddComponent <WaterVolumeProbe>();

            waterVolumeProbe._Target     = target;
            waterVolumeProbe._Targetted  = true;
            waterVolumeProbe._Size       = size;
            waterVolumeProbe._Exclusions = target.GetComponentsInChildren <WaterVolumeSubtract>(true);
            return(waterVolumeProbe);
        }
Exemple #2
0
 private void CreateWaterProbe()
 {
     if (this._WaterProbe == null)
     {
         this._WaterProbe = WaterVolumeProbe.CreateProbe(this._RigidBody.transform, this._LocalCollider.bounds.extents.magnitude);
         this._WaterProbe.Enter.AddListener(new UnityAction(this.OnWaterEnter));
         this._WaterProbe.Leave.AddListener(new UnityAction(this.OnWaterLeave));
     }
 }