Exemple #1
0
    public void ShowPath(float angle)
    {
        string json = Json.Serialize(GetPathDict());
        AIPath p    = new AIPath(json);

        p.SetAngle(angle);
        p.SetCenter(center.GetComponent <RectTransform>().anchoredPosition);
        p.SetTrackRadius(onscreenRadius);
        List <Vector2> pathpoints = p.GetPathAsListOfVectors();

        for (int i = 0; i < pathpoints.Count; i++)
        {
            Vector2 pointA = pathpoints[i];

            GameObject newpreview = new GameObject();
            newpreview.transform.SetParent(previewParent.transform, false);
            Image         img = newpreview.AddComponent <Image>() as Image;
            RectTransform prt = newpreview.GetComponent <RectTransform>();
            prt.sizeDelta        = new Vector2(12f, 12f);
            img.color            = new Color(1f, .7f, .8f);
            prt.anchoredPosition = pointA;
        }
    }
Exemple #2
0
    public void ShowPath(float angle)
    {
        string json = Json.Serialize(GetPathDict ());
        AIPath p = new AIPath(json);
        p.SetAngle(angle);
        p.SetCenter(center.GetComponent<RectTransform>().anchoredPosition);
        p.SetTrackRadius(onscreenRadius);
        List<Vector2> pathpoints = p.GetPathAsListOfVectors();
        for(int i = 0; i < pathpoints.Count;i++){
            Vector2 pointA = pathpoints[i];

            GameObject newpreview = new GameObject();
            newpreview.transform.SetParent(previewParent.transform,false);
            Image img = newpreview.AddComponent<Image>() as Image;
            RectTransform prt = newpreview.GetComponent<RectTransform>();
            prt.sizeDelta = new Vector2(12f,12f);
            img.color = new Color(1f,.7f,.8f);
            prt.anchoredPosition = pointA;
        }
    }