1
0
mirror of https://github.com/Cardidi/dotween-upm-fork.git synced 2025-12-20 01:06:02 +08:00

Nicer upgrade process using EditorWindow for instructions

This commit is contained in:
Demigiant 2018-08-02 13:42:50 +02:00
parent a61f32b85e
commit 2887a8b4a5
19 changed files with 126 additions and 26 deletions

View File

@ -2,6 +2,7 @@ DOTween and DOTween Pro are copyright (c) 2014 Daniele Giardini - Demigiant
// IMPORTANT!!! /////////////////////////////////////////////
// Upgrading DOTween from versions older than 1.2.000 ///////
// (or DOTween Pro older than 1.0.000) //////////////////////
-------------------------------------------------------------
If you're upgrading your project from a version of DOTween older than 1.2.000 (or DOTween Pro older than 1.0.000) please follow these instructions carefully.
1) Import the new version in the same folder as the previous one, overwriting old files. A lot of errors will appear but don't worry

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2
guid: d3e15b806a8368742ba6f10e794d7b76
timeCreated: 1533115990
timeCreated: 1533146162
licenseType: Pro
TextureImporter:
fileIDToRecycleName: {}

View File

@ -32,7 +32,7 @@ namespace DG.Tweening
public class DOTween
{
/// <summary>DOTween's version</summary>
public static readonly string Version = "1.2.010"; // Last version before modules: 1.1.755
public static readonly string Version = "1.2.015"; // Last version before modules: 1.1.755
///////////////////////////////////////////////
// Options ////////////////////////////////////

View File

@ -34,7 +34,8 @@ namespace DG.DOTweenEditor.UI
string[] _settingsLocation = new[] {"Assets > Resources", "DOTween > Resources", "Demigiant > Resources"};
// If force is FALSE opens the window only if DOTween's version has changed
// (set to FALSE by OnPostprocessAllAssets)
// (set to FALSE by OnPostprocessAllAssets).<para/>
// NOTE: this is also called via Reflection by UpgradeWindow
public static void Open()
{
EditorWindow window = EditorWindow.GetWindow<DOTweenUtilityWindow>(true, _Title, true);

View File

@ -18,32 +18,19 @@ namespace DG.DOTweenUpgradeManager
[InitializeOnLoad]
static class Autorun
{
static readonly string _Id = "DOTweenUpgradeManager";
static Autorun()
{
_Id = Application.dataPath + _Id;
EditorApplication.update += OnUpdate;
}
bool refresh;
DateTime now = DateTime.UtcNow;
DateTime lastTime;
if (!EditorPrefs.HasKey(_Id) || !DateTime.TryParse(EditorPrefs.GetString(_Id), out lastTime)) {
refresh = true;
} else {
refresh = (now - lastTime).TotalSeconds > 60;
}
if (refresh) {
EditorPrefs.SetString(_Id, now.ToString());
EditorUtility.DisplayDialog("DOTween",
"DOTWEEN SETUP REQUIRED: new version imported." +
"\n\nSelect \"Setup DOTween...\" in DOTween's Utility Panel to set it up and add/remove Modules." +
"\n\n::::: IMPORTANT :::::" +
"\nIf you're upgrading from a DOTween version older than 1.2.000 you will see lots of errors." +
"\n1) Close and reopen the project (if you haven't already done so)" +
"\n2) Open DOTween's Utility Panel and run the Setup to activate required Modules",
"Ok"
);
}
public static void OnUpdate()
{
if (!UpgradeWindowIsOpen()) UpgradeWindow.Open();
}
static bool UpgradeWindowIsOpen()
{
return Resources.FindObjectsOfTypeAll<UpgradeWindow>().Length > 0;
}
}
}

View File

@ -52,6 +52,7 @@
<ItemGroup>
<Compile Include="Autorun.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UpgradeWindow.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

View File

@ -0,0 +1,109 @@
// Author: Daniele Giardini - http://www.demigiant.com
// Created: 2018/08/02 12:29
// License Copyright (c) Daniele Giardini
// This work is subject to the terms at http://dotween.demigiant.com/license.php
using System;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace DG.DOTweenUpgradeManager
{
class UpgradeWindow : EditorWindow
{
const string _Title = "New Version of DOTween Imported";
static readonly Vector2 _WinSize = new Vector2(400,280);
const string _DescrTitle0 = "DOTWEEN SETUP REQUIRED";
const string _DescrContent0 = "Select <color=#ffc47a><b>\"Setup DOTween...\"</b></color> in <b>DOTween's Utility Panel</b> to set it up and add/remove Modules.";
const string _DescrTitle1 = "IMPORTANT IN CASE OF UPGRADE";
const string _DescrContent1 = "If you're upgrading from a DOTween version older than <b>1.2.000</b> or <b>Pro older than 1.0.000</b>" +
" (<color=#ffc47a><i>before the introduction of DOTween Modules</i></color>)" +
" you will see lots of errors. <b>Follow these instructions</b> to fix them:";
const string _DescrContent2 = "\n<color=#94de59><b>1)</b></color> <color=#ffc47a><b>Close and reopen the project</b></color>" +
" (if you haven't already done so)" +
"\n<color=#94de59><b>2)</b></color> Open DOTween's Utility Panel" +
" and <color=#ffc47a><b>run the Setup</b></color> to activate required Modules";
#region Unity and GUI Methods
public static void Open()
{
EditorWindow window = EditorWindow.GetWindow<UpgradeWindow>(true, _Title, true);
window.minSize = _WinSize;
window.maxSize = _WinSize;
window.ShowUtility();
}
void OnGUI()
{
Styles.Init();
Rect area = new Rect(0, 0, position.width, position.height);
// Background
GUI.color = new Color(0.18f, 0.18f, 0.18f);
GUI.DrawTexture(area, Texture2D.whiteTexture);
GUI.color = Color.white;
GUILayout.Space(4);
GUILayout.Label(_DescrTitle0, Styles.descrTitle);
GUILayout.Label(_DescrContent0, Styles.descrLabel);
GUILayout.Space(12);
GUILayout.Label(_DescrTitle1, Styles.descrTitle);
GUILayout.Label(_DescrContent1, Styles.descrLabel);
GUILayout.Space(-15);
GUILayout.Label(_DescrContent2, Styles.descrLabel);
// Buttons
GUILayout.Space(12);
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
if (GUILayout.Button("Open DOTween Utility Panel", GUILayout.Height(30))) {
Type doeditorT = Type.GetType("DG.DOTweenEditor.UI.DOTweenUtilityWindow, DOTweenEditor");
MethodInfo miOpen = doeditorT.GetMethod("Open", BindingFlags.Static | BindingFlags.Public);
miOpen.Invoke(null, null);
EditorApplication.update -= Autorun.OnUpdate;
this.Close();
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
#endregion
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
// ███ INTERNAL CLASSES ████████████████████████████████████████████████████████████████████████████████████████████████
// █████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
static class Styles
{
static bool _initialized;
public static GUIStyle descrTitle, descrLabel;
public static void Init()
{
if (_initialized) return;
_initialized = true;
descrTitle = new GUIStyle(GUI.skin.label);
descrTitle.richText = true;
descrTitle.fontSize = 18;
SetTextColor(descrTitle, new Color(0.58f, 0.87f, 0.35f));
descrLabel = new GUIStyle(GUI.skin.label);
descrLabel.fontSize = 12;
descrLabel.wordWrap = descrLabel.richText = true;
SetTextColor(descrLabel, new Color(0.93f, 0.93f, 0.93f));
}
static void SetTextColor(GUIStyle style, Color color)
{
style.normal.textColor = style.active.textColor = style.focused.textColor = style.hover.textColor
= style.onNormal.textColor = style.onActive.textColor = style.onFocused.textColor = style.onHover.textColor = color;
}
}
}
}

Binary file not shown.

View File

@ -2,6 +2,7 @@ DOTween and DOTween Pro are copyright (c) 2014 Daniele Giardini - Demigiant
// IMPORTANT!!! /////////////////////////////////////////////
// Upgrading DOTween from versions older than 1.2.000 ///////
// (or DOTween Pro older than 1.0.000) //////////////////////
-------------------------------------------------------------
If you're upgrading your project from a version of DOTween older than 1.2.000 (or DOTween Pro older than 1.0.000) please follow these instructions carefully.
1) Import the new version in the same folder as the previous one, overwriting old files. A lot of errors will appear but don't worry