Пример #1
0
        Handle AddHandle(Shape shape, Vector2 pos)
        {
            string name = GameObjectUtility.GetUniqueNameForSibling(shape.transform, "Handle");
            Handle handle = Handle.CreateHandle(name, pos);
            handle.transform.SetParent(shape.transform, false);
            handle.gameObject.SetActive(false);

            return handle;
        }
Пример #2
0
        static void CreateBezierHandle(MenuCommand menuCommand)
        {
            Handle handle = Handle.CreateHandle("Handle", Vector2.zero);

            GameObjectUtility.SetParentAndAlign(handle.gameObject, GetShape(menuCommand.context));

            Undo.RegisterCreatedObjectUndo(handle.gameObject, "Create " + handle.name);
            Selection.activeObject = handle.gameObject;
        }
Пример #3
0
        public static Shape CreateRect(string name, Vector2 size, float cornerRadius = 0)
        {
            Shape shape = CreateShape(name);

            shape.rectTransform.sizeDelta = size;

            Vector3[] localCorners = new Vector3[4];
            shape.rectTransform.GetLocalCorners(localCorners);
            foreach (Vector3 corner in localCorners)
            {
                Handle handleObj = Handle.CreateHandle("Handle", corner, cornerRadius);
                handleObj.transform.SetParent(shape.transform, false);
            }

            return(shape);
        }
Пример #4
0
        public static Shape CreatePolygon(string name, float radius, int numSides)
        {
            Shape shape = CreateShape(name);

            shape.rectTransform.sizeDelta = new Vector2(radius * 2, radius * 2);
            shape.SetReferenceSize();

            for (int i = 0; i < numSides; i++)
            {
                float   phase     = 2 * Mathf.PI * i / numSides;
                Vector2 pos       = new Vector2(Mathf.Cos(phase), Mathf.Sin(phase));
                Handle  handleObj = Handle.CreateHandle("Handle", pos * radius);
                handleObj.transform.SetParent(shape.transform, false);
            }

            return(shape);
        }