コード例 #1
0
        private GameObject CreatePathGameobject(string type, PathPoint[] positions)
        {
            lineMaterial.color = new Color(1, 0, 0, 1);

            PathMeshBuilder pb = new PathMeshBuilder();


            Vector3[] points = new Vector3[positions.Length];
            for (int i = 0; i < positions.Length; i++)
            {
                points[i] = new Vector3(positions[i].x, positions[i].y, positions[i].z);
            }


            pb.AddPoints(points);

            Mesh       m  = pb.GetMesh();
            GameObject go = new GameObject();;

            go.AddComponent <MeshFilter>();
            go.AddComponent <MeshRenderer>();
            go.GetComponent <MeshFilter>().mesh       = m;
            go.GetComponent <MeshFilter>().sharedMesh = m;
            go.GetComponent <MeshRenderer>().material = lineMaterial;
            go.transform.localPosition = new Vector3(0, 3, 0);

            foreach (VehicleDisplay t in config.vehicleTypes)
            {
                if (t.id == type)
                {
                    go.GetComponent <MeshRenderer>().enabled = t.onOff;
                }
            }
            return(go);
        }
コード例 #2
0
        private GameObject CreatePathGameobject(string type, PathPoint[] positions)
        {
            lineMaterial.color = new Color(1, 0, 0, 1);

            PathMeshBuilder pb = new PathMeshBuilder();

            if (type == "Citizen/Foot" || type == "Citizen/Cycle")
            {
                //Citizens have much tighter paths, to remove duplicate points so much
                //pb.duplicatePointThreshold = 0.0f;
                pb.tightNormalScaleFactor = 0.05f;
                pb.pathBreakThreshold     = 300.0f; //If a path segemnt is longer than this they are riding a bus/metro/train
                pb.maxNormalSize          = 30.0f;
            }

            pb.AddPoints(positions);

            Mesh       m  = pb.GetMesh();
            GameObject go = new GameObject();;

            go.AddComponent <MeshFilter>();
            go.AddComponent <MeshRenderer>();
            go.GetComponent <MeshFilter>().mesh       = m;
            go.GetComponent <MeshFilter>().sharedMesh = m;
            go.GetComponent <MeshRenderer>().material = lineMaterial;
            go.transform.localPosition = new Vector3(0, 3, 0);

            go.SetActive(Config.instance.IsTypeVisible(type));

            return(go);
        }
コード例 #3
0
        private GameObject CreatePathGameobject(string type, PathPoint[] positions)
        {
            lineMaterial.color = new Color(1, 0, 0, 1);

            PathMeshBuilder pb = new PathMeshBuilder();

            if (type == "Citizen/Foot" || type == "Citizen/Cycle")
            {
                //Citizens have much tighter paths, to remove duplicate points so much
                //pb.duplicatePointThreshold = 0.0f;
                pb.tightNormalScaleFactor = 0.05f;
                pb.pathBreakThreshold = 300.0f;  //If a path segemnt is longer than this they are riding a bus/metro/train
                pb.maxNormalSize = 30.0f;
            }

            pb.AddPoints(positions);

            Mesh m = pb.GetMesh();
            GameObject go = new GameObject(); ;
            go.AddComponent<MeshFilter>();
            go.AddComponent<MeshRenderer>();
            go.GetComponent<MeshFilter>().mesh = m;
            go.GetComponent<MeshFilter>().sharedMesh = m;
            go.GetComponent<MeshRenderer>().material = lineMaterial;
            go.transform.localPosition = new Vector3(0, 3, 0);

            go.SetActive(Config.instance.IsTypeVisible(type));

            return go;
        }