Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How ok is it to copy Unity Editor Code for a public package?

Discussion in 'Scripting' started by ayellowpaper, Jan 14, 2021.

  1. ayellowpaper

    ayellowpaper

    Joined:
    Dec 8, 2013
    Posts:
    49
    Hey,

    there's a lot of Unity Code that is internal for no apparent reason. I could use reflection but that might break my package later on if anything changes. How ok is it to copy a small bit of code, especially if it's mostly of mathematical nature to my small package? Specifically in my case I'm talking about this function in MathUtils.cs:

    Code (CSharp):
    1.         internal static float RoundBasedOnMinimumDifference(float valueToRound, float minDifference)
    2.         {
    3.             if (minDifference == 0)
    4.                 return DiscardLeastSignificantDecimal(valueToRound);
    5.             return (float)System.Math.Round(valueToRound, GetNumberOfDecimalsForMinimumDifference(minDifference), System.MidpointRounding.AwayFromZero);
    6.         }
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    Joe-Censored and ayellowpaper like this.
  3. ayellowpaper

    ayellowpaper

    Joined:
    Dec 8, 2013
    Posts:
    49
    Thanks, that's exactly what I mean. I've read the license and strictly speaking it's not allowed, but on the other hand there aren't that many ways to round based on minimum difference. So I guess I'll just write my own code inspired by Unity.
     
    Joe-Censored likes this.
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    If you want to use it verbatim, you could try asking Unity directly. Though you might not get any response to that kind of question.