Example #1
0
        public static void UnrotateAndJumpToCurrentWaypoint()
        {
            // PrefabUtility.;
            Saw saw = SelectionExtensions.GetInstance <Saw>();

            foreach (Transform waypoint in saw.objectWithWaypoints.wayPoints)
            {
                waypoint.SetParent(null);
            }
            saw.trs.position    = saw.objectWithWaypoints.wayPoints[saw.currentWayPoint].position;
            saw.trs.eulerAngles = Vector3.zero;
            foreach (Transform waypoint in saw.objectWithWaypoints.wayPoints)
            {
                waypoint.SetParent(saw.trs);
            }
        }
Example #2
0
        public static void MakeWaypointsBetweenObjects()
        {
            Saw saw = SelectionExtensions.GetInstance <Saw>();

            Transform[] selectedTransforms = SelectionExtensions.GetSelected <Transform>();
            foreach (Transform selectedTrs in selectedTransforms)
            {
                foreach (Transform selectedTrs2 in selectedTransforms)
                {
                    if (selectedTrs != selectedTrs2)
                    {
                        LineSegment2D lineSegment = new LineSegment2D(selectedTrs.position, selectedTrs2.position);
                        float         distance    = 0;
                        do
                        {
                            Vector2 spawnPosition = lineSegment.GetPointWithDirectedDistance(distance);
                            Instantiate(saw.objectWithWaypoints.wayPointsParent.GetChild(0), spawnPosition, Quaternion.identity, saw.trs);
                            distance += saw.testDistanceBetweenWaypoints;
                        } while (distance <= lineSegment.GetLength());
                    }
                }
            }
        }