SelectableHandle.cs(19,96): error CS0426: The type name 'DrawCapFunction' does not exist in the type

I’m just a beginner, I studied as a philologist, I’m more interested in level designer, but I can’t start the game

using System.Collections.Generic;

namespace UltimateSurvival.Editor
{
    using UnityEditor;
    using UnityEngine;

    public class SelectableHandle
    {
        /// <summary>
        /// The id of the most recently processed handle.
        /// </summary>
        public static int LastHandleID;

        // Internal state for DragHandle()
        private static int m_HandleHash = "SelectableHandle".GetHashCode();


        public static bool DoHandle(Vector3 position, Quaternion rotation, float handleSize, Handles.DrawCapFunction capFunc, Color color)
        {
            bool mouseDown = false;

            int id = GUIUtility.GetControlID(m_HandleHash, FocusType.Passive);
            LastHandleID = id;

            Vector3 screenPosition = Handles.matrix.MultiplyPoint(position);
            Matrix4x4 cachedMatrix = Handles.matrix;

            var eventType = Event.current.GetTypeForControl(id);
            if(eventType == EventType.MouseDown)
            {
                if (HandleUtility.nearestControl == id && Event.current.button == 0)
                {
                    Event.current.Use();
                    mouseDown = true;
                }
            }
            else if(eventType == EventType.Repaint)
            {
                Color previousColor = Handles.color;
                Handles.color = color;

                Handles.matrix = Matrix4x4.identity;
                capFunc(id, screenPosition, rotation, handleSize);
                Handles.matrix = cachedMatrix;

                Handles.color = previousColor;
            }
            else if(eventType == EventType.Layout)
            {
                Handles.matrix = Matrix4x4.identity;
                HandleUtility.AddControl(id, HandleUtility.DistanceToCircle(screenPosition, handleSize));
                Handles.matrix = cachedMatrix;
            }

            return mouseDown;
        }
    }
}

Unfortunately I think you’re just using a very old script that is trying to use things that no longer exist in Unity’s API, namely Handles.DrawCapFunction. Maybe try replacing Handles.DrawCapFunction with System.Action<int, Vector3, Quaternion, float>

1 Like

Thank you very much, even more errors began to fly out) I’d better switch to something else)