浏览代码

Work on Welcome Screen Wizard, Merged all configuration into GameplayIngredientSettings asset

/main
Thomas Iché 5 年前
当前提交
6e83c5e8
共有 10 个文件被更改,包括 125 次插入41 次删除
  1. 8
      Editor/MenuItems.cs
  2. 56
      Editor/WelcomeScreen/WelcomeScreen.cs
  3. 6
      Runtime/LevelScripting/Callable.cs
  4. 11
      Runtime/Managers/Manager.cs
  5. 2
      Runtime/Settings/GameplayIngredientsSettings.cs.meta
  6. 8
      Runtime/Settings.meta
  7. 62
      Runtime/Settings/GameplayIngredientsSettings.cs
  8. 13
      Runtime/Managers/ManagerExclusionList.cs
  9. 0
      /Runtime/Settings/GameplayIngredientsSettings.cs.meta

8
Editor/MenuItems.cs


return PlayFromHere.IsReady;
}
#region EXCLUSION LIST
[MenuItem("Assets/Create/Gameplay Ingredients/Manager Exclusion List")]
static void CreateExclusionList()
{
AssetFactory.CreateAssetInProjectWindow<ManagerExclusionList>(string.Empty, "ManagerExclusionList.asset");
}
#endregion
#region GROUP_UNGROUP
const int kGroupMenuIndex = 500;

56
Editor/WelcomeScreen/WelcomeScreen.cs


this.position = new Rect((Screen.width / 2.0f) - WindowWidth/2, (Screen.height / 2.0f) - WindowHeight/2, WindowWidth, WindowHeight);
this.minSize = new Vector2(WindowWidth, WindowHeight);
this.maxSize = new Vector2(WindowWidth, WindowHeight);
if (!GameplayIngredientsSettings.hasSettingAsset)
wizardMode = WizardMode.FirstTimeSetup;
}
private void OnDestroy()
{
EditorApplication.update -= ShowAtStartup;
}
private enum WizardMode

Configuration = 2,
}
[SerializeField]
private WizardMode wizardMode = WizardMode.TipOfTheDay;
private void OnGUI()

{
GUILayout.FlexibleSpace();
if (GUILayout.Button(" Tips ", Styles.buttonLeft)) wizardMode = WizardMode.TipOfTheDay;
EditorGUI.BeginDisabledGroup(true);
EditorGUI.BeginDisabledGroup(true);
if (GUILayout.Button(" Configuration ", Styles.buttonRight)) wizardMode = WizardMode.Configuration;
EditorGUI.EndDisabledGroup();
GUILayout.FlexibleSpace();

using (new GUILayout.VerticalScope(EditorStyles.helpBox))
{
var tip = tips[tipIndex];
GUILayout.Label(tip.Title, Styles.tipTitle);
GUILayout.Label(tip.Title, Styles.title);
GUILayout.Label(tip.Body, Styles.tipBody);
GUILayout.Label(tip.Body, Styles.body);
GUILayout.FlexibleSpace();
using (new GUILayout.HorizontalScope())
{

void FirstTimeSetupGUI()
{
GUILayout.Label("First Time Setup", EditorStyles.boldLabel);
GUILayout.FlexibleSpace();
using (new GUILayout.VerticalScope(EditorStyles.helpBox))
{
GUILayout.Label("Welcome to Gameplay Ingredients !", Styles.title);
GUILayout.Space(12);
GUILayout.Label(@"This wizard will help you set up your project so you can use and customize scripts.
GameplayIngredients is a framework that comes with a variety of features : these can be configured in a <b>GameplayIngredientsSettings</b> asset.
This asset needs to be stored in a Resources folder.
While this is not mandatory we advise you to create it in order to be able to modify it.
", Styles.body);
GUILayout.Space(8);
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Create GameplayIngredientsSettings Asset"))
{
GameplayIngredientsSettings asset = Instantiate<GameplayIngredientsSettings>(GameplayIngredientsSettings.defaultSettings);
AssetDatabase.CreateAsset(asset, "Assets/Resources/GameplayIngredientsSettings.asset");
Selection.activeObject = asset;
}
}
GUILayout.FlexibleSpace();
}
}
void ConfigurationGUI()
{

public static GUIStyle buttonLeft;
public static GUIStyle buttonMid;
public static GUIStyle buttonRight;
public static GUIStyle tipTitle;
public static GUIStyle tipBody;
public static GUIStyle title;
public static GUIStyle body;
static Styles()
{

buttonMid.fontSize = 12;
buttonRight.fontSize = 12;
tipTitle = new GUIStyle(EditorStyles.label);
tipTitle.fontSize = 22;
title = new GUIStyle(EditorStyles.label);
title.fontSize = 22;
tipBody = new GUIStyle(EditorStyles.label);
tipBody.fontSize = 12;
tipBody.wordWrap = true;
body = new GUIStyle(EditorStyles.label);
body.fontSize = 12;
body.wordWrap = true;
body.richText = true;
}
}
}

6
Runtime/LevelScripting/Callable.cs


{
foreach (var call in calls)
{
#if CALLABLE_DEBUG
if (Debug.isDebugBuild || Application.isEditor)
if (GameplayIngredientsSettings.currentSettings.verboseCalls)
#endif
Debug.LogError("Cannot execute call: Null or Missing");
Debug.LogError($"Cannot execute Call: Null or Missing");
}
}

11
Runtime/Managers/Manager.cs


if(s_Managers.ContainsKey(typeof(T)))
return (T)s_Managers[typeof(T)];
else
{
Debug.LogError($"Manager of type '{typeof(T)}' could not be accessed. Check the excludedManagers list in your GameplayIngredientsSettings configuration file.");
}
}
static readonly Type[] kAllManagerTypes = GetAllManagerTypes();

{
var exclusionList = Resources.Load<ManagerExclusionList>("ManagerExclusionList");
var exclusionList = GameplayIngredientsSettings.currentSettings.excludedeManagers;
if(exclusionList != null && exclusionList.ExcludedManagers.ToList().Contains(type.Name))
if(exclusionList != null && exclusionList.ToList().Contains(type.Name))
Debug.LogWarning($"Found Manager : {type.Name} in Exclusion List, ignoring Creation");
Debug.Log($"Manager : {type.Name} is in GameplayIngredientSettings.excludedeManagers List: ignoring Creation");
var attrib =type.GetCustomAttribute<ManagerDefaultPrefabAttribute>();
var attrib = type.GetCustomAttribute<ManagerDefaultPrefabAttribute>();
GameObject gameObject;
if(attrib != null)

2
Runtime/Settings/GameplayIngredientsSettings.cs.meta


fileFormatVersion: 2
guid: 74a9c3ba3041de044a8b71667c2e17a8
guid: 9b86121d23ed10e40bcfa3df03459c5c
MonoImporter:
externalObjects: {}
serializedVersion: 2

8
Runtime/Settings.meta


fileFormatVersion: 2
guid: b8739a81f74937f4b815f0298618db6c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

62
Runtime/Settings/GameplayIngredientsSettings.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using NaughtyAttributes;
namespace GameplayIngredients
{
public class GameplayIngredientsSettings : ScriptableObject
{
public string[] excludedeManagers { get { return m_ExcludedManagers; } }
public bool verboseCalls { get { return m_VerboseCalls; } }
[BoxGroup("Managers")]
[SerializeField, ReorderableList, TypeDropDown(typeof(Manager))]
protected string[] m_ExcludedManagers;
[BoxGroup("Callables")]
[SerializeField, InfoBox("Verbose Calls enable logging at runtime, this can lead to performance drop, use only when debugging.",InfoBoxType.Warning, "m_VerboseCalls")]
protected bool m_VerboseCalls;
const string kAssetName = "GameplayIngredientsSettings";
public static GameplayIngredientsSettings currentSettings
{
get
{
if (hasSettingAsset)
return Resources.Load<GameplayIngredientsSettings>(kAssetName);
else
return defaultSettings;
}
}
public static bool hasSettingAsset
{
get
{
return Resources.Load<GameplayIngredientsSettings>(kAssetName) != null;
}
}
public static GameplayIngredientsSettings defaultSettings
{
get
{
if (s_DefaultSettings == null)
s_DefaultSettings = CreateDefaultSettings();
return s_DefaultSettings;
}
}
static GameplayIngredientsSettings s_DefaultSettings;
static GameplayIngredientsSettings CreateDefaultSettings()
{
var defaultAsset = CreateInstance<GameplayIngredientsSettings>();
defaultAsset.m_VerboseCalls = false;
defaultAsset.m_ExcludedManagers = new string[0];
return defaultAsset;
}
}
}

13
Runtime/Managers/ManagerExclusionList.cs


using NaughtyAttributes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace GameplayIngredients
{
public class ManagerExclusionList : ScriptableObject
{
[ReorderableList, TypeDropDown(typeof(Manager))]
public string[] ExcludedManagers;
}
}

/Runtime/Managers/ManagerExclusionList.cs.meta → /Runtime/Settings/GameplayIngredientsSettings.cs.meta

正在加载...
取消
保存