Ejemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        float   length = 0;
        Liftbot bot    = target as Liftbot;

        if (bot.path != null && bot.path.Length > 0)
        {
            Vector2[] points = bot.path;
            for (int i = 0; i < points.Length; i++)
            {
                if (bot.pingpong && i + 1 == points.Length)
                {
                    length *= 2;
                    break;
                }
                int     next    = (i + 1) % points.Length;
                Vector2 segment = points[next] - points[i];
                length += segment.magnitude;
            }
        }
        EditorGUILayout.LabelField("path length", length.ToString());
        float duration = (length / bot.flySpeed) + (bot.pingpong ? bot.path.Length * 2 - 2 : bot.path.Length) * bot.waitDuration;

        EditorGUILayout.LabelField("return time", duration.ToString());
    }
Ejemplo n.º 2
0
    void OnSceneGUI()
    {
        Liftbot bot = target as Liftbot;

        if (bot.path != null && bot.path.Length > 0)
        {
            Vector2[] points = bot.path;
            for (int i = 0; i < points.Length; i++)
            {
                if (bot.pingpong && i + 1 == points.Length)
                {
                    break;
                }
                int next = (i + 1) % points.Length;

                Vector2 origin = bot.transform.position;
                if (Application.isPlaying)
                {
                    origin = bot.origin;
                }
                Handles.DrawLine(origin + points[i], origin + points[next]);
            }
        }
    }