mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-21 01:36:05 +08:00
95 lines
4.2 KiB
C#
95 lines
4.2 KiB
C#
// Author: Daniele Giardini - http://www.demigiant.com
|
|
// Created: 2018/07/14 18:56
|
|
// License Copyright (c) Daniele Giardini
|
|
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
|
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace DG.DOTweenEditor.UI
|
|
{
|
|
public static class DOTweenUtilityWindowModules
|
|
{
|
|
static bool _hasAudioModule;
|
|
static bool _hasPhysicsModule;
|
|
static bool _hasPhysics2DModule;
|
|
static bool _hasSpriteModule;
|
|
static bool _hasUIModule;
|
|
|
|
static bool _hasTextMeshProModule;
|
|
static bool _hasTk2DModule;
|
|
|
|
public static void Refresh()
|
|
{
|
|
_hasAudioModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_AudioModule);
|
|
_hasPhysicsModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_PhysicsModule);
|
|
_hasPhysics2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_Physics2DModule);
|
|
_hasSpriteModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_SpriteModule);
|
|
_hasUIModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_UIModule);
|
|
|
|
_hasTextMeshProModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_TextMeshPro);
|
|
_hasTk2DModule = EditorUtils.HasGlobalDefine(DOTweenDefines.GlobalDefine_TK2D);
|
|
}
|
|
|
|
// Returns TRUE if it should be closed
|
|
public static bool Draw()
|
|
{
|
|
GUILayout.Label("Add/Remove Modules", EditorGUIUtils.titleStyle);
|
|
|
|
GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
|
|
GUILayout.Label("Unity", EditorGUIUtils.boldLabelStyle);
|
|
_hasAudioModule = EditorGUILayout.Toggle("Audio", _hasAudioModule);
|
|
_hasPhysicsModule = EditorGUILayout.Toggle("Physics", _hasPhysicsModule);
|
|
_hasPhysics2DModule = EditorGUILayout.Toggle("Physics2D", _hasPhysics2DModule);
|
|
_hasSpriteModule = EditorGUILayout.Toggle("Sprites", _hasSpriteModule);
|
|
_hasUIModule = EditorGUILayout.Toggle("UI", _hasUIModule);
|
|
EditorGUILayout.EndVertical();
|
|
if (EditorUtils.hasPro) {
|
|
GUILayout.BeginVertical(UnityEngine.GUI.skin.box);
|
|
GUILayout.Label("External Assets (Pro)", EditorGUIUtils.boldLabelStyle);
|
|
_hasTk2DModule = EditorGUILayout.Toggle("2D Toolkit", _hasTk2DModule);
|
|
_hasTextMeshProModule = EditorGUILayout.Toggle("TextMesh Pro", _hasTextMeshProModule);
|
|
EditorGUILayout.EndVertical();
|
|
}
|
|
|
|
GUILayout.Space(2);
|
|
GUILayout.BeginHorizontal();
|
|
if (GUILayout.Button("Apply")) {
|
|
Apply();
|
|
return true;
|
|
}
|
|
if (GUILayout.Button("Cancel")) return true;
|
|
GUILayout.EndHorizontal();
|
|
|
|
// EditorGUILayout.HelpBox(
|
|
// "NOTE: if you get \"PlayerSettings Validation\" or [CS0618] errors when you press apply don't worry:" +
|
|
// " it's ok and it allows the setup to work on all possible Unity versions",
|
|
// MessageType.Warning
|
|
// );
|
|
return false;
|
|
}
|
|
|
|
static void Apply()
|
|
{
|
|
ModifyDefineIfChanged(_hasAudioModule, DOTweenDefines.GlobalDefine_AudioModule);
|
|
ModifyDefineIfChanged(_hasPhysicsModule, DOTweenDefines.GlobalDefine_PhysicsModule);
|
|
ModifyDefineIfChanged(_hasPhysics2DModule, DOTweenDefines.GlobalDefine_Physics2DModule);
|
|
ModifyDefineIfChanged(_hasSpriteModule, DOTweenDefines.GlobalDefine_SpriteModule);
|
|
ModifyDefineIfChanged(_hasUIModule, DOTweenDefines.GlobalDefine_UIModule);
|
|
|
|
if (EditorUtils.hasPro) {
|
|
ModifyDefineIfChanged(_hasTextMeshProModule, DOTweenDefines.GlobalDefine_TextMeshPro);
|
|
ModifyDefineIfChanged(_hasTk2DModule, DOTweenDefines.GlobalDefine_TK2D);
|
|
}
|
|
}
|
|
|
|
static void ModifyDefineIfChanged(bool wantsToBeSet, string defineId)
|
|
{
|
|
bool hasDefine = EditorUtils.HasGlobalDefine(defineId);
|
|
if (wantsToBeSet != hasDefine) {
|
|
if (wantsToBeSet) EditorUtils.AddGlobalDefine(defineId);
|
|
else EditorUtils.RemoveGlobalDefine(defineId);
|
|
}
|
|
}
|
|
}
|
|
} |