Inheritance: MonoBehaviour
示例#1
0
    static public void CreateSphereVolume()
    {
        GameObject   newObject    = new GameObject("Sphere Volume");
        SphereVolume sphereVolume = (SphereVolume)newObject.AddComponent <SphereVolume>();

        sphereVolume.enabled = false;
        sphereVolume.enabled = true;
    }
示例#2
0
    static public void CreateVolume()
    {
        GameObject newObject = new GameObject("Sphere Volume");

        if (UnityEditor.SceneView.currentDrawingSceneView)
        {
            UnityEditor.SceneView.currentDrawingSceneView.MoveToView(newObject.transform);
        }
        SphereVolume sphereVolume = (SphereVolume)newObject.AddComponent <SphereVolume>();

        sphereVolume.volumeShader = "Advanced SS/Volumetric/Sphere Volume";
        sphereVolume.enabled      = false;
        sphereVolume.enabled      = true;
    }
示例#3
0
        protected virtual void addFoliage(FoliageInfoAsset foliageAsset, float weightMultiplier)
        {
            if (foliageAsset == null)
            {
                return;
            }
            float num       = 3.14159274f * this.brushRadius * this.brushRadius;
            float newRadius = Mathf.Sqrt(foliageAsset.density / DevkitFoliageToolOptions.instance.densityTarget / 3.14159274f);
            float num2;

            if (!this.addWeights.TryGetValue(foliageAsset, out num2))
            {
                this.addWeights.Add(foliageAsset, 0f);
            }
            num2 += DevkitFoliageToolOptions.addSensitivity * num * this.brushStrength * weightMultiplier * Time.deltaTime;
            if (num2 > 1f)
            {
                this.previewSamples.Clear();
                int num3 = Mathf.FloorToInt(num2);
                num2 -= (float)num3;
                for (int i = 0; i < num3; i++)
                {
                    float num4       = this.brushRadius * Random.value;
                    float brushAlpha = this.getBrushAlpha(num4);
                    if (Random.value >= brushAlpha)
                    {
                        float num5 = 6.28318548f * Random.value;
                        float num6 = Mathf.Cos(num5) * num4;
                        float num7 = Mathf.Sin(num5) * num4;
                        Ray   ray;
                        ray..ctor(this.brushWorldPosition + new Vector3(num6, this.brushRadius, num7), new Vector3(0f, -1f, 0f));
                        RaycastHit raycastHit;
                        if (PhysicsUtility.raycast(ray, out raycastHit, this.brushRadius * 2f, (int)DevkitFoliageToolOptions.instance.surfaceMask, 0))
                        {
                            SphereVolume sphereVolume = new SphereVolume(raycastHit.point, newRadius);
                            if (foliageAsset.getInstanceCountInVolume(sphereVolume) <= 0)
                            {
                                if (Input.GetKey(323))
                                {
                                    foliageAsset.addFoliageToSurface(raycastHit.point, raycastHit.normal, false, false);
                                }
                            }
                        }
                    }
                }
            }
            this.addWeights[foliageAsset] = num2;
        }