示例#1
0
        /// <summary>
        /// Determines if a build target group is obsolete (has Obsolete attribute).
        /// </summary>
        /// <returns><c>true</c> if obsolete; otherwise, <c>false</c>.</returns>
        /// <param name="target">Target.</param>
        public static bool IsBuildTargetGroupObsolete(BuildTargetGroup target)
        {
            var type       = target.GetType();
            var memberInfo = type.GetMember(target.ToString())[0];

            return(System.Attribute.IsDefined(memberInfo, typeof(System.ObsoleteAttribute)));
        }
示例#2
0
        /// <summary>
        ///     Ensure that the GDX define is present across all viable platforms.
        /// </summary>
        public static void EnsureScriptingDefineSymbol()
        {
            // Create a list of all the build targets
            Array buildTargets      = Enum.GetValues(typeof(BuildTargetGroup));
            int   buildTargetsCount = buildTargets.Length;

            // Iterate over them all - skipping unknown
            for (int i = 1; i < buildTargetsCount; i++)
            {
                // Get our object
                object target = buildTargets.GetValue(i);

                // Cast back
                BuildTargetGroup group    = (BuildTargetGroup)target;
                Type             enumType = group.GetType();

                // Check if we can find an ObsoleteAttribute
                FieldInfo fieldInfo      = enumType.GetField(Enum.GetName(enumType, target));
                Attribute foundAttribute = fieldInfo.GetCustomAttribute(typeof(ObsoleteAttribute), false);

                // It doesnt have one, so we should assume we can update the scripting defines for this target.
                if (foundAttribute != null)
                {
                    continue;
                }

                PlayerSettings.GetScriptingDefineSymbolsForGroup(group, out string[] defines);
                int location = defines.FirstIndexOfItem("GDX");

                // Found
                if (location != -1)
                {
                    continue;
                }

                // Add to it!
                int      oldLength  = defines.Length;
                string[] newDefines = new string[oldLength + 1];
                Array.Copy(defines, newDefines, oldLength);
                newDefines[oldLength] = "GDX";
                PlayerSettings.SetScriptingDefineSymbolsForGroup(@group, newDefines);
            }
        }
        static void SetScriptingSymbol(string symbol, BuildTargetGroup target, bool isActivate)
        {
            if (target == BuildTargetGroup.Unknown)
            {
                return;
            }

            var  type        = target.GetType();
            var  memInfo     = type.GetMember(target.ToString());
            var  attributes  = memInfo[0].GetCustomAttributes(typeof(BuildTargetGroup), false);
            bool continueBTG = attributes.Length > 0;

            if (!continueBTG)
            {
                return;
            }

            var s = PlayerSettings.GetScriptingDefineSymbolsForGroup(target);

            string sTemp = symbol;

            if (!s.Contains(sTemp))
            {
                s = s.Replace(symbol + ";", "");

                s = s.Replace(symbol, "");

                if (isActivate)
                {
                    s = symbol + ";" + s;
                }

                PlayerSettings.SetScriptingDefineSymbolsForGroup(target, s);
            }
//			}
        }
        bool isBuildTargetObsolete(BuildTargetGroup buildTargetGroup)
        {
            var fieldInfo = buildTargetGroup.GetType().GetField(buildTargetGroup.ToString());

            return(Attribute.IsDefined(fieldInfo, typeof(ObsoleteAttribute)));
        }
 private bool isBuildTargetObsolete(BuildTargetGroup buildTargetGroup)
 {
     return(Attribute.IsDefined(
                buildTargetGroup.GetType().GetField(buildTargetGroup.ToString()),
                typeof(ObsoleteAttribute)));
 }
 bool isBuildTargetObsolete(BuildTargetGroup buildTargetGroup)
 {
     var fieldInfo = buildTargetGroup.GetType().GetField(buildTargetGroup.ToString());
     return Attribute.IsDefined(fieldInfo, typeof(ObsoleteAttribute));
 }