Exemplo n.º 1
0
        public static void ShowItem(AltspaceListItem item)
        {
            if (WebClient.IsAuthenticated)
            {
                EditorGUILayout.LabelField("Selected " + item.friendlyName + ":");
                DisplayStatus("  Name:", "none", item.itemName);
                DisplayStatus("  ID:", "none", item.id);
            }

            if (item.isSelected)
            {
                if (item.asset_bundles != null)
                {
                    EditorGUILayout.Space(10);

                    EditorGUILayout.LabelField(item.friendlyName.Capitalize() + " contents:");

                    DescribeAssetBundles(item.asset_bundles);
                }
                else if (!String.IsNullOrEmpty(item.item_url))
                {
                    EditorGUILayout.Space(10);

                    EditorGUILayout.LabelField(item.friendlyName.Capitalize() + " URL:");

                    EditorGUILayout.LabelField(item.item_url);
                }
            }
        }
            public static HttpContent GLTFContent(AltspaceListItem item)
            {
                var zipContents = new ByteArrayContent(File.ReadAllBytes(item.itemPath));

                zipContents.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");

                return(new MultipartFormDataContent
                {
                    { zipContents, item.type + "[gltf]", item.bundleName + ".glb" }
                });
            }
            public static HttpContent BundleContent(AltspaceListItem item, Parameters parm)
            {
                var zipContents = new ByteArrayContent(File.ReadAllBytes(parm.uploadFileName));

                zipContents.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");

                var colorSpace = PlayerSettings.colorSpace == ColorSpace.Linear ? "linear" : "gamma";
                var srp        = PlayerSettings.stereoRenderingPath == StereoRenderingPath.Instancing
                    ? (parm.isExclusivelyAndroid ? "spmv" : "spi")
                    : (PlayerSettings.stereoRenderingPath == StereoRenderingPath.SinglePass)
                        ? "sp"
                        : "mp";

                return(new MultipartFormDataContent
                {
                    { new StringContent("" + Common.usingUnityVersion), item.type + "[game_engine_version]" },
                    { new StringContent(srp), item.type + "[stereo_render_mode]" },
                    { new StringContent(colorSpace), item.type + "[color_space]" },
                    { zipContents, item.type + "[zip]", item.bundleName + ".zip" }
                });
            }
        public static void ManageItem(AltspaceListItem item, Action showSelection_fn, Action <string> updateItem_fn, string missingString)
        {
            void BuildItem(AltspaceListItem subItem)
            {
                string       state  = subItem.buildAssetBundle(SettingsManager.SelectedBuildTargets) ? "finished" : "canceled";
                LoginManager window = EditorWindow.GetWindow <LoginManager>();

                window.ShowNotification(new GUIContent(subItem.friendlyName.Capitalize() + " build " + state), 5.0f);
            }

            void BuildAndUploadItem(AltspaceListItem subItem, Action <string> updategui_fn)
            {
                LoginManager.BuildAndUploadAltVRItem(SettingsManager.SelectedBuildTargets, subItem);

                updategui_fn(subItem.id);

                LoginManager window = EditorWindow.GetWindow <LoginManager>();

                window.ShowNotification(new GUIContent(subItem.friendlyName.Capitalize() + " upload finished"), 5.0f);
            }

            void UploadFlatItem(AltspaceListItem subItem, Action <string> updategui_fn)
            {
                LoginManager.ManageAltVRItem(subItem);

                updategui_fn(subItem.id);

                LoginManager window = EditorWindow.GetWindow <LoginManager>();

                window.ShowNotification(new GUIContent(subItem.friendlyName.Capitalize() + " upload finished"), 5.0f);
            }

            if (WebClient.IsAuthenticated)
            {
                if (GUILayout.Button("Select " + item.friendlyName.Capitalize()))
                {
                    showSelection_fn();
                }
            }
            else
            {
                EditorGUILayout.LabelField("Offline mode", new GUIStyle()
                {
                    fontStyle = FontStyle.Bold,
                    alignment = TextAnchor.MiddleCenter
                });
            }

            EditorGUILayout.Space(10);

            item.showSelf();

            EditorGUILayout.BeginHorizontal();

            if (!item.isSet)
            {
                GUILayout.Label(missingString, new GUIStyle()
                {
                    fontStyle = FontStyle.Bold,
                    alignment = TextAnchor.MiddleCenter
                });
            }
            else if (item.exists)
            {
                if (item.isAssetBundleItem)
                {
                    if (GUILayout.Button("Build"))
                    {
                        EditorApplication.delayCall += () => BuildItem(item);
                    }

                    if (item.isSelected)
                    {
                        if (GUILayout.Button("Build & Upload"))
                        {
                            EditorApplication.delayCall += () => BuildAndUploadItem(item, updateItem_fn);
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button("Upload"))
                    {
                        EditorApplication.delayCall += () => UploadFlatItem(item, updateItem_fn);
                    }
                }
            }

            EditorGUILayout.EndHorizontal();
        }