Exemplo n.º 1
0
        public static void SetXRLoaderEnabled(string loaderClassName, BuildTargetGroup buildTargetGroup, bool enabled)
        {
#if VIU_XR_GENERAL_SETTINGS
            MethodInfo method = Type.GetType("UnityEditor.XR.Management.XRSettingsManager, Unity.XR.Management.Editor")
                                .GetProperty("currentSettings", BindingFlags.NonPublic | BindingFlags.Static).GetGetMethod(true);
            XRGeneralSettingsPerBuildTarget generalSettings = (XRGeneralSettingsPerBuildTarget)method.Invoke(null, new object[] {});

            XRGeneralSettings xrSettings = generalSettings.SettingsForBuildTarget(buildTargetGroup);

            if (xrSettings == null)
            {
                xrSettings = ScriptableObject.CreateInstance <XRGeneralSettings>() as XRGeneralSettings;
                generalSettings.SetSettingsForBuildTarget(buildTargetGroup, xrSettings);
                xrSettings.name = $"{buildTargetGroup.ToString()} Settings";
                AssetDatabase.AddObjectToAsset(xrSettings, AssetDatabase.GetAssetOrScenePath(generalSettings));
            }

            var serializedSettingsObject  = new SerializedObject(xrSettings);
            SerializedProperty loaderProp = serializedSettingsObject.FindProperty("m_LoaderManagerInstance");
            if (loaderProp.objectReferenceValue == null)
            {
                var xrManagerSettings = ScriptableObject.CreateInstance <XRManagerSettings>() as XRManagerSettings;
                xrManagerSettings.name = $"{buildTargetGroup.ToString()} Providers";
                AssetDatabase.AddObjectToAsset(xrManagerSettings, AssetDatabase.GetAssetOrScenePath(generalSettings));
                loaderProp.objectReferenceValue = xrManagerSettings;
                serializedSettingsObject.ApplyModifiedProperties();
            }

            if (enabled)
            {
#if VIU_XR_PACKAGE_METADATA_STORE
                if (!UnityEditor.XR.Management.Metadata.XRPackageMetadataStore.AssignLoader(xrSettings.AssignedSettings, loaderClassName, buildTargetGroup))
                {
                    Debug.LogWarning("Failed to assign XR loader: " + loaderClassName);
                }
#else
                if (!AssignLoader(xrSettings.AssignedSettings, loaderClassName))
                {
                    Debug.LogWarning("Failed to assign XR loader: " + loaderClassName);
                }
#endif
            }
            else
            {
#if VIU_XR_PACKAGE_METADATA_STORE
                if (!UnityEditor.XR.Management.Metadata.XRPackageMetadataStore.RemoveLoader(xrSettings.AssignedSettings, loaderClassName, buildTargetGroup))
                {
                    Debug.LogWarning("Failed to remove XR loader: " + loaderClassName);
                }
#else
                if (!RemoveLoader(xrSettings.AssignedSettings, loaderClassName))
                {
                    Debug.LogWarning("Failed to remove XR loader: " + loaderClassName);
                }
#endif
            }
#endif
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="target">Unknown is Default Texture Platform for now.</param>
        /// <returns></returns>
        public TextureImporterPlatformSettings GetTextureImporterPlatformSettings(
            BuildTargetGroup target = BuildTargetGroup.Unknown)
        {
            TextureImporterPlatformSettings settings = null;

            switch (target)
            {
            case BuildTargetGroup.Unknown:
                settings = new TextureImporterPlatformSettings
                {
                    name                = "DefaultTexturePlatform",
                    maxTextureSize      = MaxTextureSize,
                    resizeAlgorithm     = ResizeAlgorithm,
                    format              = Format,
                    textureCompression  = TextureCompression,
                    crunchedCompression = CrunchedCompression,
                    compressionQuality  = CompressionQuality
                };
                break;

            case BuildTargetGroup.Standalone:
                settings = new TextureImporterPlatformSettings
                {
                    name               = target.ToString(),
                    overridden         = OverrideStandalone,
                    maxTextureSize     = MaxTextureSizeStandalone,
                    resizeAlgorithm    = ResizeAlgorithmStandalone,
                    format             = FormatStandalone,
                    textureCompression = TextureCompressionStandalone,
                    compressionQuality = CompressionQualityStandalone
                };
                break;

            case BuildTargetGroup.Android:
                settings = new TextureImporterPlatformSettings
                {
                    name                        = target.ToString(),
                    overridden                  = OverrideAndroid,
                    maxTextureSize              = MaxTextureSizeAndroid,
                    resizeAlgorithm             = ResizeAlgorithmAndroid,
                    format                      = FormatAndroid,
                    textureCompression          = TextureCompressionAndroid,
                    compressionQuality          = CompressionQualityAndroid,
                    allowsAlphaSplitting        = SplitAlphaChannel,
                    androidETC2FallbackOverride = androidETC2FallbackOverride
                };
                break;
            }

            return(settings);
        }
            public void ShowDropDown(TobiiXR_Settings settings, ref string eyeTrackingProviderTypeString)
            {
                EditorGUI.BeginChangeCheck();
                var selected = EditorGUILayout.Popup(_targetGroup.ToString(), SelectedType, TypeStrings);

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(settings, _targetGroup.ToString() + " Provider changed");
                    SelectedType = selected;
                    eyeTrackingProviderTypeString = TypeString;
                    SetDirty(settings);
                    EditorUtils.UpdateCompilerFlags(settings);
                }
            }
Exemplo n.º 4
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)));
        }
        public static void SendBuildEvent(GUID guid, BuildTarget buildTarget, BuildTargetGroup buildTargetGroup, IEnumerable <XRLoader> loaders)
        {
#if UNITY_ANALYTICS && ENABLE_CLOUD_SERVICES_ANALYTICS
            if (!s_Initialized && !Initialize())
            {
                return;
            }

            List <string> loaderTypeNames = new List <string>();
            foreach (var loader in loaders)
            {
                loaderTypeNames.Add(loader.GetType().Name);
            }

            var data = new BuildEvent
            {
                buildGuid        = guid.ToString(),
                buildTarget      = buildTarget.ToString(),
                buildTargetGroup = buildTargetGroup.ToString(),
                assigned_loaders = loaderTypeNames.ToArray(),
            };

            EditorAnalytics.SendEventWithLimit(kEventBuild, data);
#endif //UNITY_ANALYTICS && ENABLE_CLOUD_SERVICES_ANALYTICS
        }
    internal static string ToPlatformDisplayName(this BuildTargetGroup value)
    {
        switch (value)
        {
        case BuildTargetGroup.iOS:
        {
            // TRICKY: Prefer an "iOS" string on BuildTarget, to avoid the unwanted "BuildTargetGroup.iPhone"
            return(BuildTarget.iOS.ToString());
        }

        case BuildTargetGroup.Standalone:
        {
            switch (EditorUserBuildSettings.activeBuildTarget)
            {
            case BuildTarget.StandaloneOSX:
                return("macOS");

            case BuildTarget.StandaloneWindows:
                return("Windows");

            default:
                return(BuildTargetGroup.Standalone.ToString());
            }
        }

        default:
            return(value.ToString());
        }
    }
Exemplo n.º 7
0
    private void DrawBuildTargetGroup(BuildTargetGroup buildTargetGroup, ref string newDefine)
    {
        EditorGUILayout.BeginVertical();

        EditorGUILayout.LabelField(string.Format("Platform: {0}", buildTargetGroup.ToString()), EditorStyles.boldLabel);
        EditorGUILayout.LabelField("Define symbols:", EditorStyles.boldLabel);
        EditorGUILayout.Space();

        EditorGUILayout.BeginHorizontal();
        newDefine = EditorGUILayout.TextField(newDefine);
        EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(newDefine));
        if (GUILayout.Button("Add"))
        {
            DefinesEditor.AddDefine(buildTargetGroup, newDefine);
            newDefine = string.Empty;
        }
        EditorGUI.EndDisabledGroup();
        EditorGUILayout.EndHorizontal();

        var defines = DefinesEditor.GetDefines(buildTargetGroup);

        foreach (var define in defines)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(define);
            if (GUILayout.Button("Remove"))
            {
                DefinesEditor.RemoveDefine(buildTargetGroup, define);
            }
            EditorGUILayout.EndHorizontal();
        }
        DrawCommonDefines(buildTargetGroup, defines);

        EditorGUILayout.EndVertical();
    }
Exemplo n.º 8
0
        static void EnableVR(BuildTargetGroup buildTargetGroup)
        {
            if (!UnityEditor.PlayerSettings.GetVirtualRealitySupported(buildTargetGroup))
            {
                Debug.Log("Enabling Virtual Reality for " + buildTargetGroup.ToString());
                UnityEditor.PlayerSettings.SetVirtualRealitySupported(buildTargetGroup, true);

                // Set the VR SDK to either Vuforia or Windows Mixed Reality based on VuforiaConfiguration settings
                // Vuforia: Suports ARVR Stereo Viewer mode for Android/iOS or StereoRendering for ODG
                // Windows Mixed Reality: Supports HoloLens

                string vrSDK = (buildTargetGroup == BuildTargetGroup.WSA) ? "WindowsMR" : "Vuforia";
                Debug.Log("Setting Virtual Reality SDK to " + vrSDK + " for " + buildTargetGroup.ToString());
                UnityEditor.PlayerSettings.SetVirtualRealitySDKs(buildTargetGroup, new[] { vrSDK });
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 设定宏.
        /// </summary>
        /// <param name="iDefines">宏.</param>
        /// <param name="iTargetGroup">目标组.</param>
        public static void SetDefines(DefineInfo[] iDefines, BuildTargetGroup iTargetGroup)
        {
            if ((null == iDefines) || (0 >= iDefines.Length))
            {
                return;
            }

            string _defines = null;

            foreach (DefineInfo define in iDefines)
            {
                if (true == string.IsNullOrEmpty(define.Name))
                {
                    continue;
                }
                if (true == string.IsNullOrEmpty(_defines))
                {
                    _defines = define.Name;
                }
                else
                {
                    _defines = string.Format("{0};{1}", _defines, define.Name);
                }
            }
            if (false == string.IsNullOrEmpty(_defines))
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(iTargetGroup, _defines);
                UtilsLog.Info("DefinesSetting", "SetDefines -> Target:{0} Defines:{1}", iTargetGroup, _defines);
                BuildLogger.LogMessage("DefinesSetting()::Defines({0}):{1}",
                                       iTargetGroup.ToString(), _defines);
            }
        }
Exemplo n.º 10
0
    static void DefaultBuild(BuildTarget buildTarget)
    {
        BuildTargetGroup targetGroup = ConvertBuildTarget(buildTarget);

        string path = Path.Combine(Path.Combine(BuildPathRoot, targetGroup.ToString()), ProductName + "_" + System.DateTime.Now.ToString("dd.MM.yyyy_HH") + "h" + System.DateTime.Now.ToString("mm") + "_" + buildTarget);
        string name = ProductName + GetExtension(buildTarget);


        string defineSymbole = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);

        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole + ";BUILD");

        PlayerSettings.Android.keystorePass = androidKeystorePass;
        PlayerSettings.Android.keyaliasName = androidKeyaliasName;
        PlayerSettings.Android.keyaliasPass = androidKeyaliasPass;

        BuildPlayerOptions buildPlayerOptions = GetDefaultPlayerOptions();

        buildPlayerOptions.locationPathName = Path.Combine(path, name);
        buildPlayerOptions.target           = buildTarget;

        EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, buildTarget);

        string result = buildPlayerOptions.locationPathName + ": " + BuildPipeline.BuildPlayer(buildPlayerOptions);

        Debug.Log(result);
        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole);

        if (buildTarget == BuildTarget.Android)
        {
            AndroidLastBuildVersionCode = PlayerSettings.Android.bundleVersionCode;
        }

        UnityEditor.EditorUtility.RevealInFinder(path);
    }
Exemplo n.º 11
0
        public OpenXRSettings GetSettingsForBuildTargetGroup(BuildTargetGroup buildTargetGroup)
        {
            OpenXRSettings ret = null;

            Settings.TryGetValue(buildTargetGroup, out ret);
            if (ret == null)
            {
                if (!IsValidBuildTargetGroup(buildTargetGroup))
                {
                    return(null);
                }

                ret = ScriptableObject.CreateInstance <OpenXRSettings>();
                if (Settings.ContainsKey(buildTargetGroup))
                {
                    Settings[buildTargetGroup] = ret;
                }
                else
                {
                    Settings.Add(buildTargetGroup, ret);
                }

                ret.name = buildTargetGroup.ToString();

                AssetDatabase.AddObjectToAsset(ret, this);
            }

            return(ret);
        }
Exemplo n.º 12
0
    private static bool IsObsolete(BuildTargetGroup group)
    {
        var attrs = typeof(BuildTargetGroup).GetField(group.ToString())
                    .GetCustomAttributes(typeof(ObsoleteAttribute), false);

        return(attrs != null && attrs.Length > 0);
    }
Exemplo n.º 13
0
 static void EnableVuforia(BuildTargetGroup buildTargetGroup)
 {
     if (!PlayerSettings.GetPlatformVuforiaEnabled(buildTargetGroup))
     {
         Debug.Log("Enabling Vuforia for " + buildTargetGroup.ToString());
         PlayerSettings.SetPlatformVuforiaEnabled(buildTargetGroup, true);
     }
 }
Exemplo n.º 14
0
        public static bool IsObsolete(this BuildTargetGroup group)
        {
            var obsoleteAttributes = typeof(BuildTargetGroup)
                                     .GetField(group.ToString())
                                     .GetCustomAttributes(typeof(ObsoleteAttribute), false);

            return(obsoleteAttributes != null && obsoleteAttributes.Length > 0);
        }
Exemplo n.º 15
0
        // --------------------
        static public bool IsBuildTargetGroupSupported(BuildTargetGroup btg)
        {
            if (((int)btg < 0) || (btg == BuildTargetGroup.Unknown))
            {
                return(false);
            }

            string btgName = btg.ToString().ToLower();

            if (btgName.Length == 0)
            {
                return(false);
            }

//#if !UNITY_PRE_5_0
//		if (btg == BuildTargetGroup.iPhone)			return false;
//#else

#if !UNITY_PRE_5_4
            if (btgName == "wp8")
            {
                return(false);
            }
            if (btgName == "blackberry")
            {
                return(false);
            }
            if (btgName == "webplayer")
            {
                return(false);
            }
#endif

#if !UNITY_PRE_5_5
            if (btgName == "ps3")
            {
                return(false);
            }
            if (btgName == "xbox360")
            {
                return(false);
            }
#endif


            if ((int)btg >= 27)
            {
                return(false); // Ugly hack for missing Switch target in Unity 5.6.
            }
#if UNITY_2017_1_OR_NEWER
            if ((int)btg == 22) // SamsungTV
            {
                return(false);
            }
#endif

            return(true);
        }
Exemplo n.º 16
0
    public void OnDraw()
    {
        EditorGUILayout.BeginHorizontal();
        {
            EditorGUILayout.LabelField("宏名称");
            EditorGUILayout.LabelField("描述");
            EditorGUILayout.LabelField("启用", GUILayout.Width(100));


            if (GUILayout.Button("+"))
            {
                macroItems.Add(new MacroItem());
            }
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.TextField(targetGroup.ToString(), macroDef);

        if (macroItems == null)
        {
            return;
        }


        EditorGUI.BeginChangeCheck();
        {
            pos = EditorGUILayout.BeginScrollView(pos);
            {
                for (int i = 0; i < macroItems.Count; i++)
                {
                    var item = macroItems[i];
                    EditorGUILayout.BeginHorizontal();
                    {
                        item.Name     = EditorGUILayout.TextField(item.Name);
                        item.Describe = EditorGUILayout.TextField(item.Describe);
                        item.isEnable = EditorGUILayout.Toggle(item.isEnable, GUILayout.Width(100));

                        if (GUILayout.Button("x"))
                        {
                            if (EditorUtility.DisplayDialog("提示", "是否删除", "是", "取消"))
                            {
                                macroItems.RemoveAt(i);
                                return;
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    macroItems[i] = item;
                }
            }
            EditorGUILayout.EndScrollView();
        }
        if (EditorGUI.EndChangeCheck())
        {
            Update();
        }
    }
Exemplo n.º 17
0
        private static void DefinePreProcessors(bool defineHDRP, bool defineURP)
        {
            string originalDefineSymbols;
            string newDefineSymbols;

            List <string>    defined;
            BuildTargetGroup platform = EditorUserBuildSettings.selectedBuildTargetGroup;


            originalDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(platform);
            defined = originalDefineSymbols.Split(';').Where(x => !String.IsNullOrWhiteSpace(x)).ToList();

            Action <bool, string> AppendRemoveTag = (stat, tag) =>
            {
                if (stat && !defined.Contains(tag))
                {
                    defined.Add(tag);
                }
                else if (!stat && defined.Contains(tag))
                {
                    defined.Remove(tag);
                }
            };

            AppendRemoveTag(defineHDRP, TAG_HDRP);
            AppendRemoveTag(defineURP, TAG_URP);

            newDefineSymbols = string.Join(";", defined);

            string log = "";

            if (originalDefineSymbols != newDefineSymbols)
            {
                PlayerSettings.SetScriptingDefineSymbolsForGroup(platform, newDefineSymbols);
                log += "Platform " + platform.ToString() + "Old Define Symbols: " + originalDefineSymbols;
                log += "Platform " + platform.ToString() + "New Define Symbols: " + newDefineSymbols;
            }

            if (LOG_NEW_DEFINE_SYMBOLS && !String.IsNullOrEmpty(log))
            {
                Debug.Log("PlayerSetting Define Symbols have been updated. Log: " + log);
            }
        }
Exemplo n.º 18
0
        /// <summary> テクスチャ設定取得 </summary>
        public static TextureImporterPlatformSettings GetPlatformTextureSetting(this TextureImporter importer, BuildTargetGroup platform)
        {
            var settings = new TextureImporterPlatformSettings();

            var platformTextureSetting = importer.GetPlatformTextureSettings(platform.ToString());

            platformTextureSetting.CopyTo(settings);

            return(settings);
        }
Exemplo n.º 19
0
        private static bool CheckPlatformSettings(SpriteAtlas atlas, SpriteAtlasSettings settings, BuildTargetGroup buildTargetGroup)
        {
            var atlasPlatformSettings = atlas.GetPlatformSettings(buildTargetGroup.ToString());
            var platformSettings      = settings.ImportSettings.GetTextureImporterPlatformSettings(buildTargetGroup);

            return(atlasPlatformSettings.textureCompression == platformSettings.textureCompression &&
                   atlasPlatformSettings.maxTextureSize == platformSettings.maxTextureSize &&
                   atlasPlatformSettings.format == platformSettings.format &&
                   atlasPlatformSettings.crunchedCompression == platformSettings.crunchedCompression &&
                   atlasPlatformSettings.compressionQuality == platformSettings.compressionQuality);
        }
Exemplo n.º 20
0
 public static string GetShortName(this BuildTargetGroup targetGroup)
 {
     if (targetGroup == BuildTargetGroup.iOS)
     {
         return("iOS");
     }
     if (targetGroup == BuildTargetGroup.WSA)
     {
         return("UWP");
     }
     return(targetGroup.ToString());
 }
Exemplo n.º 21
0
        // --------------------
        static public bool IsBuildTargetGroupSupported(BuildTargetGroup btg)
        {
            if (((int)btg < 0) || (btg == BuildTargetGroup.Unknown))
            {
                return(false);
            }

            string btgName = btg.ToString().ToLower();

            if (btgName.Length == 0)
            {
                return(false);
            }

//#if !UNITY_PRE_5_0
//		if (btg == BuildTargetGroup.iPhone)			return false;
//#else

#if !UNITY_PRE_5_4
            if (btgName == "wp8")
            {
                return(false);
            }
            if (btgName == "blackberry")
            {
                return(false);
            }
            if (btgName == "webplayer")
            {
                return(false);
            }
#endif

#if !UNITY_PRE_5_5
            if (btgName == "ps3")
            {
                return(false);
            }
            if (btgName == "xbox360")
            {
                return(false);
            }
#endif



//BuildTargetGroup.Metro (dep)
//BuildTargetGroup.WebPlayer
//BuildTargetGroup.WP8
//BuildTargetGroup.iPhone

            return(true);
        }
Exemplo n.º 22
0
            public bool ShowDropDown(ref string eyeTrackingProviderTypeString, string label = null)
            {
                label = label == null?_targetGroup.ToString() : label;

                EditorGUI.BeginChangeCheck();
                var selected = EditorGUILayout.Popup(label, SelectedType, TypeStringDisplayNames);

                if (EditorGUI.EndChangeCheck())
                {
                    SelectedType = selected;
                    eyeTrackingProviderTypeString = TypeString;

                    _providerSettings = GetProviderSettingsFor(eyeTrackingProviderTypeString);
                    if (_providerSettings != null)
                    {
                        _providerSettings.Init();
                    }
                    return(true);
                }

                return(false);
            }
Exemplo n.º 23
0
        private static bool CheckBuildTarget(BuildTargetGroup buildTarget)
        {
            // Not available id Unknown.
            if (buildTarget == BuildTargetGroup.Unknown)
            {
                return(false);
            }

            // Or Obsolete.
            var buildTargetString = buildTarget.ToString();
            var field             = typeof(BuildTargetGroup).GetField(buildTargetString);

            return(!Attribute.IsDefined(field, typeof(ObsoleteAttribute), true));
        }
Exemplo n.º 24
0
        //...
        static bool ValidateBuildTarget(BuildTargetGroup target)
        {
            if (target == BuildTargetGroup.Unknown)
            {
                return(false);
            }
            var field = typeof(BuildTargetGroup).GetField(target.ToString());

            if (field.IsDefined(typeof(System.ObsoleteAttribute), true))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 25
0
        public static Texture2D FindIcon(BuildTargetGroup target, bool small = false)
        {
            var name = "";

            switch (target)
            {
            case BuildTargetGroup.iOS: name = "iPhone"; break;

            default: name = target.ToString(); break;
            }
            var path = string.Format("BuildSettings.{0}{1}", name, small ? ".small" : "");

            return(EditorGUIUtility.FindTexture(path));
        }
        bool ValidateBuildTarget(BuildTargetGroup target)
        {
            if (target == BuildTargetGroup.Unknown)
            {
                return(false);
            }
            var field = typeof(BuildTargetGroup).GetField(target.ToString());

            if (field.GetCustomAttributes(typeof(System.ObsoleteAttribute), true).FirstOrDefault() != null)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 27
0
    static void DefaultBuild(BuildTarget buildTarget)
    {
        Debug.Log("DefaultBuild, buildTarget = " + buildTarget);
        if (buildTarget == BuildTarget.NoTarget)
        {
            Debug.Log("buildTarget is BuildTarget.NoTarget, skip build");
            return;
        }

        BuildTargetGroup targetGroup = GetBuildTargetGroup(buildTarget);

        string path = Path.Combine(Path.Combine(OUTPUT_PATH_VALUE, targetGroup.ToString()), PlayerSettings.productName + "_" + System.DateTime.Now.ToString("yyyy-MM-dd_HH") + "h" + System.DateTime.Now.ToString("mm") + "_" + buildTarget);
        string name = PlayerSettings.productName + GetExtension(buildTarget);


        //string defineSymbole = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
        //PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole + ";BUILD");

        //PlayerSettings.Android.keystorePass = androidKeystorePass;
        //PlayerSettings.Android.keyaliasName = androidKeyaliasName;
        //PlayerSettings.Android.keyaliasPass = androidKeyaliasPass;

        BuildPlayerOptions buildPlayerOptions = GetDefaultPlayerOptions();

        buildPlayerOptions.locationPathName = Path.Combine(path, name);
        buildPlayerOptions.target           = buildTarget;

        EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, buildTarget);

        string result = BuildPipeline.BuildPlayer(buildPlayerOptions);

        Debug.Log(result);
        if (UnityEditorInternal.InternalEditorUtility.inBatchMode)
        {
            if (!string.IsNullOrEmpty(result))
            {
                Debug.Log("BuildPlayer fail!!! result = " + result);
                EditorApplication.Exit(1);
            }
        }
        //PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole);

        //if (buildTarget == BuildTarget.Android)
        //AndroidLastBuildVersionCode = PlayerSettings.Android.bundleVersionCode;

        //UnityEditor.EditorUtility.RevealInFinder(path);
    }
Exemplo n.º 28
0
            public static Texture2D FindIcon(BuildTargetGroup target, bool small = false)
            {
                string name = string.Empty;

                switch (target)
                {
                case BuildTargetGroup.iOS: name = "iPhone"; break;

                default: name = target.ToString(); break;
                }
                if (string.IsNullOrEmpty(name))
                {
                    return(null);
                }
                string path = string.Format("BuildSettings.{0}{1}", name, small ? ".small" : "");

                return(EditorGUIUtility.FindTexture(path));
            }
Exemplo n.º 29
0
            static Texture LoadIcon(BuildTargetGroup target)
            {
                var textureName = target.ToString();

                // iOSは古いiPhoneの名前で存在してるらしい
                if (target == BuildTargetGroup.iOS)
                {
                    textureName = "iPhone";
                }

                var icon = EditorGUIUtility.Load(string.Format("BuildSettings.{0}", textureName)) as Texture;

                if (icon == null)
                {
                    icon = EditorGUIUtility.Load(string.Format("d_BuildSettings.{0}", textureName)) as Texture;
                }
                return(icon);
            }
Exemplo n.º 30
0
        /**
         *  from build target group to human friendly string for display purpose.
         */
        public static string GroupToHumaneString(BuildTargetGroup g)
        {
            switch (g)
            {
            case BuildTargetGroup.Android:
                return("Android");

            case BuildTargetGroup.iOS:
                return("iOS");

            case BuildTargetGroup.PS4:
                return("PlayStation 4");

            case BuildTargetGroup.Standalone:
                return("PC/Mac/Linux Standalone");

            case BuildTargetGroup.tvOS:
                return("tvOS");

            case BuildTargetGroup.WebGL:
                return("WebGL");

            case BuildTargetGroup.WSA:
                return("Windows Store Apps");

            case BuildTargetGroup.XboxOne:
                return("Xbox One");

            case BuildTargetGroup.Unknown:
                return("Unknown");

                        #if !UNITY_2019_3_OR_NEWER
            case BuildTargetGroup.Facebook:
                return("Facebook");
                        #endif
            case BuildTargetGroup.Switch:
                return("Nintendo Switch");

            default:
                return(g.ToString() + "(deprecated)");
            }
        }
 bool isBuildTargetObsolete(BuildTargetGroup buildTargetGroup)
 {
     var fieldInfo = buildTargetGroup.GetType().GetField(buildTargetGroup.ToString());
     return Attribute.IsDefined(fieldInfo, typeof(ObsoleteAttribute));
 }