Ejemplo n.º 1
0
        static GameObject CreateGPUWater(bool collider2D)
        {
            GameObject   fmObject    = new GameObject("New Water2D_FM");
            Water2D_Tool water2DTool = fmObject.AddComponent <Water2D_Tool>();

            fmObject.AddComponent <Water2D_Simulation>();
            fmObject.AddComponent <Water2D_Ripple>();

            water2DTool.Add(new Vector3(0, 3, 0));
            water2DTool.Add(new Vector3(0, -3, 0));
            water2DTool.Add(new Vector3(-8, 0, 0));
            water2DTool.Add(new Vector3(8, 0, 0));
            water2DTool.Add(new Vector3(0, 3, 10));

            if (!collider2D)
            {
                water2DTool.use3DCollider = true;
            }

            water2DTool.squareSegments  = true;
            water2DTool.segmentsPerUnit = 4;
            water2DTool.cubeWater       = true;

            GameObject tmObject = new GameObject("New Water2D_TM");

            tmObject.AddComponent <MeshRenderer>();
            tmObject.AddComponent <MeshFilter>();
            tmObject.AddComponent <Water2D_PlanarReflection>();
            tmObject.transform.position = water2DTool.transform.position;
            tmObject.transform.SetParent(water2DTool.transform);
            water2DTool.topMeshGameObject = tmObject;


            water2DTool.SetGPUWaterDefaultMaterial();
            water2DTool.RecreateWaterMesh();

            fmObject.transform.position = GetSpawnPos();

            return(fmObject);
        }
Ejemplo n.º 2
0
        static GameObject CreateWater2D(bool collider2D)
        {
            GameObject   obj   = new GameObject("New Water2D_FM");
            Water2D_Tool water = obj.AddComponent <Water2D_Tool>();

            obj.AddComponent <Water2D_Simulation>();

            water.Add(new Vector2(0, 3));
            water.Add(new Vector2(0, -3));
            water.Add(new Vector2(-5, 0));
            water.Add(new Vector2(5, 0));

            if (!collider2D)
            {
                water.use3DCollider = true;
            }

            water.SetDefaultMaterial();
            water.RecreateWaterMesh();

            obj.transform.position = GetSpawnPos();

            return(obj);
        }