示例#1
0
 /// <summary>
 /// Sets the server type (only used when the remote adaptor type
 /// is <see cref="AssetBundleAdaptorType.AssetBundleServer" />).
 /// </summary>
 /// <param name="serverType">
 /// The server type.
 /// </param>
 /// <remarks>
 /// <para>
 /// The server type must be set before bootstrapping the <see cref="AssetBundleAdaptorMap" />
 /// (so the <see cref="AssetBundleServerInfo" /> in the <see cref="AssetBundleMap" /> can be
 /// resolved to <see cref="ServerAdaptorOptions" /> in the <see cref="AssetBundleAdaptorMap" />).
 /// </para>
 /// <para>
 /// In Cloud Build, the server type will need to be set using one of the following define symbols:
 /// <code>
 /// SAGO_ASSET_BUNDLES_USE_DEVELOPMENT_SERVER
 /// SAGO_ASSET_BUNDLES_USE_STAGING_SERVER
 /// SAGO_ASSET_BUNDLES_USE_PRODUCTION_SERVER
 /// </code>
 /// </para>
 /// <para>
 /// In the editor, the server type will need be set by the method that
 /// starts a build. We don't want to use define symbols in the editor
 /// because the server type is build-specific and shouldn't be committed
 /// to the repository (define symbols are stored in Unity's project
 /// settings which are committed to the repository).
 /// </para>
 /// </remarks>
 public static void SetServerType(AssetBundleServerType serverType)
 {
     #if !(UNITY_CLOUD_BUILD || TEAMCITY_BUILD)
     if (serverType == AssetBundleServerType.Unknown)
     {
         EditorPrefs.DeleteKey(ServerTypeKey);
     }
     else
     {
         EditorPrefs.SetInt(ServerTypeKey, (int)serverType);
     }
                 #endif
 }
        public static void PlatformDropDown(Rect rect, List <AssetBundleServerInfo> list, AssetBundleServerType serverType, System.Action <AssetBundleServerInfo> block)
        {
            Platform[] allPlatforms;
            allPlatforms = (
                PlatformUtil
                .AllPlatforms
                .ToArray()
                );

            Platform[] existingPlatforms;
            existingPlatforms = (
                list
                .Where(value => value.ServerType.Equals(serverType))
                .Select(value => value.Platform)
                .ToArray()
                );

            GenericMenu menu;

            menu = new GenericMenu();

            for (int index = 0; index < allPlatforms.Length; index++)
            {
                Platform platform;
                platform = allPlatforms[index];

                GenericMenu.MenuFunction callback;
                callback = () => {
                    AssetBundleServerInfo value;
                    value            = new AssetBundleServerInfo();
                    value.Platform   = platform;
                    value.ServerType = serverType;

                    block(value);
                };

                GUIContent content;
                content = new GUIContent(GetPlaformName(platform));

                if (System.Array.IndexOf(existingPlatforms, platform) != -1)
                {
                    menu.AddDisabledItem(content);
                }
                else
                {
                    menu.AddItem(content, false, callback);
                }
            }

            menu.DropDown(rect);
        }
 public static string GetFoldoutKey(AssetBundleServerType serverType, Platform platform)
 {
     return(string.Format("{0}.{1}.{2}", GetFoldoutKey(), serverType.ToString(), platform.ToString()));
 }