Unity内实现类似 UE4函数 MapRangeClamp

    
float MapRangeClamp(float value, float InFrom, float InEnd, float OutFrom, float OutEnd)
    {
        value = Mathf.Clamp(value, InFrom, InEnd);
        float InLength = Mathf.Abs(InEnd - InFrom);
        float LengthValueToFrom = Mathf.Abs(value - InFrom);
        float curPercent = LengthValueToFrom / InLength;
        //Debug.Log(curPercent);

        float ff = OutFrom + (OutEnd- OutFrom) * curPercent;
        //Debug.Log(ff);
        return ff;
    }

 

你可能感兴趣的:(unity3D,ue4)