public override void SetSelection(MeshSelection selection)
        {
            if (m_faceSelection != null)
            {
                m_faceSelection.Clear();
            }

            if (selection != null)
            {
                selection = selection.ToFaces(false);

                m_faceSelection.BeginChange();

                foreach (KeyValuePair <GameObject, IList <int> > kvp in selection.SelectedFaces)
                {
                    ProBuilderMesh mesh   = kvp.Key.GetComponent <ProBuilderMesh>();
                    PBMesh         pbMesh = mesh.GetComponent <PBMesh>();
                    if (pbMesh.IsMarkedAsDestroyed)
                    {
                        continue;
                    }
                    foreach (int face in kvp.Value)
                    {
                        m_faceSelection.Add(mesh, face);
                    }
                }

                m_faceSelection.EndChange();
            }
        }
Exemple #2
0
    void Initialize()
    {
        Vector3[] points     = new Vector3[UVLength * UVLength];
        Face[]    faces      = new Face[(UVLength - 1) * (UVLength - 1)];
        float     xThreshold = (edgeLength) / UVLength;

        for (int i = 0; i < points.Length; i++)
        {
            points[i] = new Vector3(center.x + (xThreshold * (i % UVLength)), center.y, center.z + (xThreshold * (i / UVLength)));
        }
        int j = 0;

        for (int i = 0; i < points.Length - UVLength; i++)
        {
            if (i % UVLength != UVLength - 1)
            {
                faces[j] = new Face(new int[] { i, i + 1, i + UVLength, i + 1, i + UVLength + 1, i + UVLength });
                j++;
            }
        }

        ground = ProBuilderMesh.Create(points, faces);
        ground.CenterPivot(new int[] { 0, UVLength - 1, UVLength * (UVLength - 1), (UVLength * UVLength) - 1 });
        ground.Refresh();
        MeshRenderer meshRend = ground.GetComponent <MeshRenderer>();

        meshRend.material         = fogMaterial;
        ground.transform.position = center;
        ground.gameObject.layer   = 9;
        ground.gameObject.name    = "fog";
        ground.gameObject.AddComponent <MeshCollider>();
        ground.transform.Rotate(new Vector3(180f, 0, 0));
        ground.transform.localScale = (new Vector3(1 / 3f, 1 / 3f, 1 / 3f));
    }
Exemple #3
0
    public static ProBuilderMesh MeshRoadNetwork(RoadNetwork roadNet)
    {
        var(vertices, faces) = CalcVerticesAndFaces(roadNet);
        ProBuilderMesh roadMesh = ProBuilderMesh.Create(vertices, faces);

        roadMesh.GetComponent <Renderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;

        return(roadMesh);
    }
    public void Setup()
    {
        ProBuilderMesh shape1 = ShapeFactory.Instantiate <Cube>();

        shape1.transform.position = Vector3.zero - shape1.GetComponent <MeshRenderer>().bounds.center;

        selectables = new ProBuilderMesh[]
        {
            shape1
        };
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        Initialize();

        m_mesh     = ground.GetComponent <MeshFilter>().mesh;
        m_vertices = m_mesh.vertices;
        m_colors   = new Color[m_vertices.Length];
        for (int i = 0; i < m_colors.Length; i++)
        {
            m_colors[i] = initialColor;
        }
    }