Example #1
0
        public override void OnInspectorGUI()
        {
            if (AssetStoreAssetInspector.styles == null)
            {
                AssetStoreAssetInspector.s_SharedAssetStoreAssetInspector = this;
                AssetStoreAssetInspector.styles = new AssetStoreAssetInspector.Styles();
            }
            AssetStoreAsset firstAsset = AssetStoreAssetSelection.GetFirstAsset();

            AssetStoreAsset.PreviewInfo previewInfo = null;
            if (firstAsset != null)
            {
                previewInfo = firstAsset.previewInfo;
            }
            if (firstAsset != null)
            {
                base.target.name = string.Format("Asset Store: {0}", firstAsset.name);
            }
            else
            {
                base.target.name = "Asset Store";
            }
            EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
            bool enabled = GUI.enabled;

            GUI.enabled = (firstAsset != null && firstAsset.packageID != 0);
            if (AssetStoreAssetInspector.OfflineNoticeEnabled)
            {
                Color color = GUI.color;
                GUI.color = Color.yellow;
                GUILayout.Label("Network is offline", new GUILayoutOption[0]);
                GUI.color = color;
            }
            if (firstAsset != null)
            {
                string label = (firstAsset.className != null) ? firstAsset.className.Split(new char[]
                {
                    ' '
                }, 2)[0] : "";
                bool flag = firstAsset.id == -firstAsset.packageID;
                if (flag)
                {
                    label = "Package";
                }
                if (firstAsset.HasLivePreview)
                {
                    label = firstAsset.Preview.GetType().Name;
                }
                EditorGUILayout.LabelField("Type", label, new GUILayoutOption[0]);
                if (flag)
                {
                    this.packageInfoShown = true;
                }
                else
                {
                    EditorGUILayout.Separator();
                    this.packageInfoShown = EditorGUILayout.Foldout(this.packageInfoShown, "Part of package", true);
                }
                if (this.packageInfoShown)
                {
                    EditorGUILayout.LabelField("Name", (previewInfo != null) ? previewInfo.packageName : "-", new GUILayoutOption[0]);
                    EditorGUILayout.LabelField("Version", (previewInfo != null) ? previewInfo.packageVersion : "-", new GUILayoutOption[0]);
                    string label2 = (previewInfo != null) ? ((firstAsset.price == null || !(firstAsset.price != "")) ? "free" : firstAsset.price) : "-";
                    EditorGUILayout.LabelField("Price", label2, new GUILayoutOption[0]);
                    string label3 = (previewInfo == null || previewInfo.packageRating < 0) ? "-" : (previewInfo.packageRating.ToString() + " of 5");
                    EditorGUILayout.LabelField("Rating", label3, new GUILayoutOption[0]);
                    EditorGUILayout.LabelField("Size", (previewInfo != null) ? AssetStoreAssetInspector.intToSizeString(previewInfo.packageSize) : "-", new GUILayoutOption[0]);
                    string label4 = (previewInfo == null || previewInfo.packageAssetCount < 0) ? "-" : previewInfo.packageAssetCount.ToString();
                    EditorGUILayout.LabelField("Asset count", label4, new GUILayoutOption[0]);
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    EditorGUILayout.PrefixLabel("Web page");
                    bool flag2    = previewInfo != null && previewInfo.packageShortUrl != null && previewInfo.packageShortUrl != "";
                    bool enabled2 = GUI.enabled;
                    GUI.enabled = flag2;
                    if (GUILayout.Button((!flag2) ? EditorGUIUtility.TempContent("-") : new GUIContent(previewInfo.packageShortUrl, "View in browser"), AssetStoreAssetInspector.styles.link, new GUILayoutOption[0]))
                    {
                        Application.OpenURL(previewInfo.packageShortUrl);
                    }
                    if (GUI.enabled)
                    {
                        EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
                    }
                    GUI.enabled = enabled2;
                    GUILayout.EndHorizontal();
                    EditorGUILayout.LabelField("Publisher", (previewInfo != null) ? previewInfo.publisherName : "-", new GUILayoutOption[0]);
                }
                if (firstAsset.id != 0)
                {
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    GUILayout.FlexibleSpace();
                    string text;
                    if (previewInfo != null && previewInfo.isDownloadable)
                    {
                        text = "Import package";
                    }
                    else
                    {
                        text = "Buy for " + firstAsset.price;
                    }
                    bool enabled3 = GUI.enabled;
                    bool flag3    = previewInfo != null && previewInfo.buildProgress >= 0f;
                    bool flag4    = previewInfo != null && previewInfo.downloadProgress >= 0f;
                    if (flag3 || flag4 || previewInfo == null)
                    {
                        text        = "";
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button(text, new GUILayoutOption[]
                    {
                        GUILayout.Height(40f),
                        GUILayout.Width(120f)
                    }))
                    {
                        if (previewInfo.isDownloadable)
                        {
                            this.ImportPackage(firstAsset);
                        }
                        else
                        {
                            this.InitiateBuySelected();
                        }
                        GUIUtility.ExitGUI();
                    }
                    if (Event.current.type == EventType.Repaint)
                    {
                        Rect lastRect = GUILayoutUtility.GetLastRect();
                        lastRect.height -= 4f;
                        float width = lastRect.width;
                        lastRect.width = lastRect.height;
                        lastRect.y    += 2f;
                        lastRect.x    += 2f;
                        if (flag3 || flag4)
                        {
                            lastRect.width = width - lastRect.height - 4f;
                            lastRect.x    += lastRect.height;
                            EditorGUI.ProgressBar(lastRect, (!flag4) ? previewInfo.buildProgress : previewInfo.downloadProgress, (!flag4) ? "Building" : "Downloading");
                        }
                    }
                    GUI.enabled = enabled3;
                    GUILayout.Space(4f);
                    if (GUILayout.Button("Open Asset Store", new GUILayoutOption[]
                    {
                        GUILayout.Height(40f),
                        GUILayout.Width(120f)
                    }))
                    {
                        AssetStoreAssetInspector.OpenItemInAssetStore(firstAsset);
                        GUIUtility.ExitGUI();
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }
                GUILayout.FlexibleSpace();
            }
            EditorWrapper previewEditor = this.previewEditor;

            if (previewEditor != null && firstAsset != null && firstAsset.HasLivePreview)
            {
                previewEditor.OnAssetStoreInspectorGUI();
            }
            GUI.enabled = enabled;
            EditorGUILayout.EndVertical();
        }
		public override void OnInspectorGUI()
		{
			if (AssetStoreAssetInspector.styles == null)
			{
				AssetStoreAssetInspector.s_SharedAssetStoreAssetInspector = this;
				AssetStoreAssetInspector.styles = new AssetStoreAssetInspector.Styles();
			}
			AssetStoreAsset firstAsset = AssetStoreAssetSelection.GetFirstAsset();
			AssetStoreAsset.PreviewInfo previewInfo = null;
			if (firstAsset != null)
			{
				previewInfo = firstAsset.previewInfo;
			}
			if (firstAsset != null)
			{
				this.target.name = string.Format("Asset Store: {0}", firstAsset.name);
			}
			else
			{
				this.target.name = "Asset Store";
			}
			EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
			bool enabled = GUI.enabled;
			GUI.enabled = (firstAsset != null && firstAsset.packageID != 0);
			if (AssetStoreAssetInspector.OfflineNoticeEnabled)
			{
				Color color = GUI.color;
				GUI.color = Color.yellow;
				GUILayout.Label("Network is offline", new GUILayoutOption[0]);
				GUI.color = color;
			}
			if (firstAsset != null)
			{
				string label = (firstAsset.className != null) ? firstAsset.className.Split(new char[]
				{
					' '
				}, 2)[0] : string.Empty;
				bool flag = firstAsset.id == -firstAsset.packageID;
				if (flag)
				{
					label = "Package";
				}
				if (firstAsset.HasLivePreview)
				{
					label = firstAsset.Preview.GetType().Name;
				}
				EditorGUILayout.LabelField("Type", label, new GUILayoutOption[0]);
				if (flag)
				{
					this.packageInfoShown = true;
				}
				else
				{
					EditorGUILayout.Separator();
					this.packageInfoShown = EditorGUILayout.Foldout(this.packageInfoShown, "Part of package");
				}
				if (this.packageInfoShown)
				{
					EditorGUILayout.LabelField("Name", (previewInfo != null) ? previewInfo.packageName : "-", new GUILayoutOption[0]);
					EditorGUILayout.LabelField("Version", (previewInfo != null) ? previewInfo.packageVersion : "-", new GUILayoutOption[0]);
					string label2 = (previewInfo != null) ? ((firstAsset.price == null || !(firstAsset.price != string.Empty)) ? "free" : firstAsset.price) : "-";
					EditorGUILayout.LabelField("Price", label2, new GUILayoutOption[0]);
					string label3 = (previewInfo == null || previewInfo.packageRating < 0) ? "-" : (previewInfo.packageRating.ToString() + " of 5");
					EditorGUILayout.LabelField("Rating", label3, new GUILayoutOption[0]);
					EditorGUILayout.LabelField("Size", (previewInfo != null) ? AssetStoreAssetInspector.intToSizeString(previewInfo.packageSize) : "-", new GUILayoutOption[0]);
					string label4 = (previewInfo == null || previewInfo.packageAssetCount < 0) ? "-" : previewInfo.packageAssetCount.ToString();
					EditorGUILayout.LabelField("Asset count", label4, new GUILayoutOption[0]);
					GUILayout.BeginHorizontal(new GUILayoutOption[0]);
					EditorGUILayout.PrefixLabel("Web page");
					bool flag2 = previewInfo != null && previewInfo.packageShortUrl != null && previewInfo.packageShortUrl != string.Empty;
					bool enabled2 = GUI.enabled;
					GUI.enabled = flag2;
					if (GUILayout.Button((!flag2) ? EditorGUIUtility.TempContent("-") : new GUIContent(previewInfo.packageShortUrl, "View in browser"), AssetStoreAssetInspector.styles.link, new GUILayoutOption[0]))
					{
						Application.OpenURL(previewInfo.packageShortUrl);
					}
					if (GUI.enabled)
					{
						EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);
					}
					GUI.enabled = enabled2;
					GUILayout.EndHorizontal();
					EditorGUILayout.LabelField("Publisher", (previewInfo != null) ? previewInfo.publisherName : "-", new GUILayoutOption[0]);
				}
				if (firstAsset.id != 0)
				{
					GUILayout.BeginHorizontal(new GUILayoutOption[0]);
					GUILayout.FlexibleSpace();
					string text;
					if (previewInfo != null && previewInfo.isDownloadable)
					{
						text = "Import package";
					}
					else
					{
						text = "Buy for " + firstAsset.price;
					}
					bool enabled3 = GUI.enabled;
					bool flag3 = previewInfo != null && previewInfo.buildProgress >= 0f;
					bool flag4 = previewInfo != null && previewInfo.downloadProgress >= 0f;
					if (flag3 || flag4 || previewInfo == null)
					{
						text = string.Empty;
						GUI.enabled = false;
					}
					if (GUILayout.Button(text, new GUILayoutOption[]
					{
						GUILayout.Height(40f),
						GUILayout.Width(120f)
					}))
					{
						if (previewInfo.isDownloadable)
						{
							this.ImportPackage(firstAsset);
						}
						else
						{
							this.InitiateBuySelected();
						}
						GUIUtility.ExitGUI();
					}
					if (Event.current.type == EventType.Repaint)
					{
						Rect lastRect = GUILayoutUtility.GetLastRect();
						lastRect.height -= 4f;
						float width = lastRect.width;
						lastRect.width = lastRect.height;
						lastRect.y += 2f;
						lastRect.x += 2f;
						if (flag3 || flag4)
						{
							lastRect.width = width - lastRect.height - 4f;
							lastRect.x += lastRect.height;
							EditorGUI.ProgressBar(lastRect, (!flag4) ? previewInfo.buildProgress : previewInfo.downloadProgress, (!flag4) ? "Building" : "Downloading");
						}
					}
					GUI.enabled = enabled3;
					GUILayout.Space(4f);
					if (GUILayout.Button("Open Asset Store", new GUILayoutOption[]
					{
						GUILayout.Height(40f),
						GUILayout.Width(120f)
					}))
					{
						AssetStoreAssetInspector.OpenItemInAssetStore(firstAsset);
						GUIUtility.ExitGUI();
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}
				GUILayout.FlexibleSpace();
			}
			EditorWrapper previewEditor = this.previewEditor;
			if (previewEditor != null && firstAsset != null && firstAsset.HasLivePreview)
			{
				previewEditor.OnAssetStoreInspectorGUI();
			}
			GUI.enabled = enabled;
			EditorGUILayout.EndVertical();
		}