Skip to content

Commit

Permalink
fix: paths for welcome window changelog.
Browse files Browse the repository at this point in the history
fix: allow 2019 and up for welcome window.

Signed-off-by: dragonslaya <steve.s@bigredplanetgames.com>
  • Loading branch information
dragonslaya-ss committed Jun 19, 2021
1 parent b9f9ef6 commit a1ec86d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Assets/Mirage/Editor/WelcomeWindow/WelcomeWindow.cs
Expand Up @@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.IO;
using Mirage.Logging;
using Newtonsoft.Json;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.Requests;
using UnityEngine;
using UnityEngine.UIElements;
using Object = System.Object;
using PackageInfo = UnityEditor.PackageManager.PackageInfo;

/**
Expand Down Expand Up @@ -62,6 +64,7 @@ public class WelcomeWindow : EditorWindow
//editorprefs keys
private static string firstStartUpKey = string.Empty;
private const string firstTimeMirageKey = "MirageWelcome";
private const string packageName = "com.miragenet.mirage";

/// <summary>
/// Hard coded for source code version. If package version is found, this will
Expand Down Expand Up @@ -108,7 +111,7 @@ private static void ShowWindowOnFirstStart()
{
EditorPrefs.SetString(screenToOpenKey, ShowChangeLog ? "ChangeLog" : "Welcome");

#if UNITY_2020_1_OR_NEWER
#if UNITY_2019_1_OR_NEWER
OpenWindow();
#else
if (logger.LogEnabled()) logger.Log($"WelcomeWindow not supported in {Application.unityVersion}, it is only supported in Unity 2020.1 or newer");
Expand Down Expand Up @@ -138,6 +141,8 @@ public static void OpenWindow()
//the code to handle display and button clicking
private void OnEnable()
{
CheckForPackageManager();

//Load the UI
//Each editor window contains a root VisualElement object
VisualElement root = rootVisualElement;
Expand Down Expand Up @@ -206,6 +211,18 @@ private void ConfigureTab(string tabButtonName, string tab, string url)
}
}

private void CheckForPackageManager()
{
// we just check the manifest manually. It's JSON format, so it's easy to read.
string jsonText = File.ReadAllText("Packages/manifest.json");

var manifest = JsonConvert.DeserializeObject<Dictionary<string, object>>(jsonText);

var packages = JsonConvert.DeserializeObject<Dictionary<string, string>>(Convert.ToString(manifest["dependencies"]));

changeLogPath = packages.ContainsKey(packageName) ? "Packages/com.miragenet.mirage/CHANGELOG.md" : "Assets/Mirage/CHANGELOG.md";
}

//switch between content
private void ShowTab(string screen)
{
Expand Down Expand Up @@ -429,12 +446,6 @@ private void ListPackageProgress()
continue;
}

if (miragePackage.Value.packageName != null && miragePackage.Value.packageName.Equals("Mirage"))
{
// Found mirage package let's set up our change log path.
changeLogPath = "Packages/com.miragenet.mirage/CHANGELOG.md";
}

installedPackages.Add(miragePackage.Value.displayName);
}

Expand Down

0 comments on commit a1ec86d

Please sign in to comment.