Exemplo n.º 1
0
        public static GameObject MakeLinkGo(SceneMan sman, LcLink link, float linkRadius, string clrname, float alf, bool flatlink = false)
        {
            var go     = new GameObject();
            var linkgo = go.AddComponent <LinkGo>();

            linkgo.sman      = sman;
            linkgo.link      = link;
            linkgo.name      = link.name;
            linkgo.linkName  = link.name;
            linkgo.nodeName1 = link.node1.name;
            linkgo.nodeName2 = link.node2.name;
            //linkgo.node1 = link.node1.go.GetComponent<NodeGo>();
            //linkgo.node2 = link.node2.go.GetComponent<NodeGo>();


            go.name = link.name; //  + "-go";
            var p1    = link.node1.pt;
            var p2    = link.node2.pt;
            var midpt = (p1 + p2) / 2;

            go.transform.localPosition = midpt;
            GameObject linkcyl;

            if (flatlink)
            {
                linkcyl = GraphUtil.CreateFlatPipe(link.name, p1, p2, linkRadius, clrname, alf);
            }
            else
            {
                linkcyl = GraphUtil.CreatePipe(link.name, p1, p2, linkRadius, clrname, alf);
            }
            if (sman != null && sman.garnish != RouteGarnishE.none)
            {
                var text   = link.name;
                var anglat = GraphUtil.GetAngLatDegrees(p1, p2);
                GraphUtil.addFloatingTextStatic(go, midpt, text + "  ang:" + anglat, clrname, anglat + 90);
            }
            linkcyl.transform.parent = go.transform;
            return(go);
        }