浏览代码

Split Welcome Script into partial class. Removed Config and made about box.

/main
Thomas Iché 6 年前
当前提交
be908ede
共有 5 个文件被更改,包括 198 次插入86 次删除
  1. 152
      Editor/WelcomeScreen/WelcomeScreen.cs
  2. 41
      Editor/WelcomeScreen/WelcomeScreen.Setup.cs
  3. 11
      Editor/WelcomeScreen/WelcomeScreen.Setup.cs.meta
  4. 69
      Editor/WelcomeScreen/WelcomeScreen.Tips.cs
  5. 11
      Editor/WelcomeScreen/WelcomeScreen.Tips.cs.meta

152
Editor/WelcomeScreen/WelcomeScreen.cs


namespace GameplayIngredients.Editor
{
class WelcomeScreen : EditorWindow
partial class WelcomeScreen : EditorWindow
{
const string kShowOnStartupPreference = "GameplayIngredients.Welcome.ShowAtStartup";
const int WindowWidth = 640;

{
if (showOnStartup)
EditorApplication.update += ShowAtStartup;
if(!Application.isPlaying)
if (!Application.isPlaying)
{
ShowFromMenu();
}

[MenuItem("Window/Gameplay Ingredients/Startup Wizard")]
[MenuItem("Window/Gameplay Ingredients")]
static void ShowFromMenu()
{
GetWindow<WelcomeScreen>(true, "Gameplay Ingredients");

{
this.position = new Rect((Screen.width / 2.0f) - WindowWidth/2, (Screen.height / 2.0f) - WindowHeight/2, WindowWidth, WindowHeight);
this.position = new Rect((Screen.width / 2.0f) - WindowWidth / 2, (Screen.height / 2.0f) - WindowHeight / 2, WindowWidth, WindowHeight);
InitTips();
}
private void OnDestroy()

{
TipOfTheDay = 0,
FirstTimeSetup = 1,
Configuration = 2,
About = 2,
}
[SerializeField]

using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button(" Tips ", Styles.buttonLeft)) wizardMode = WizardMode.TipOfTheDay;
if (GUILayout.Button(" Setup ", Styles.buttonMid)) wizardMode = WizardMode.FirstTimeSetup;
EditorGUI.BeginDisabledGroup(true);
if (GUILayout.Button(" Configuration ", Styles.buttonRight)) wizardMode = WizardMode.Configuration;
EditorGUI.EndDisabledGroup();
bool value = false;
value = wizardMode == WizardMode.TipOfTheDay;
value = GUILayout.Toggle(value, " Tips ", Styles.buttonLeft);
if(value)
wizardMode = WizardMode.TipOfTheDay;
value = wizardMode == WizardMode.FirstTimeSetup;
value = GUILayout.Toggle(value, " Setup ", Styles.buttonMid);
if (value)
wizardMode = WizardMode.FirstTimeSetup;
value = wizardMode == WizardMode.About;
value = GUILayout.Toggle(value, " About ", Styles.buttonRight);
if(value)
wizardMode = WizardMode.About;
GUILayout.FlexibleSpace();
}
}

{
case WizardMode.TipOfTheDay: TipOfTheDayGUI();
case WizardMode.TipOfTheDay:
OnTipsGUI();
case WizardMode.FirstTimeSetup: FirstTimeSetupGUI();
case WizardMode.FirstTimeSetup:
OnSetupGUI();
case WizardMode.Configuration: ConfigurationGUI();
case WizardMode.About:
OnAboutGUI();
break;
}

}
}
int tipIndex = 0;
void TipOfTheDayGUI()
{
GUILayout.Label("Tip of the Day", EditorStyles.boldLabel);
using (new GUILayout.VerticalScope(EditorStyles.helpBox))
{
var tip = tips[tipIndex];
GUILayout.Label(tip.Title, Styles.title);
GUILayout.Space(12);
GUILayout.Label(tip.Body, Styles.body);
GUILayout.FlexibleSpace();
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if(GUILayout.Button("<<"))
{
tipIndex--;
if (tipIndex < 0)
tipIndex = tips.Count - 1;
}
if(GUILayout.Button(">>"))
{
tipIndex++;
if (tipIndex == tips.Count)
tipIndex = 0;
}
}
}
}
void FirstTimeSetupGUI()
void OnAboutGUI()
GUILayout.Label("First Time Setup", EditorStyles.boldLabel);
GUILayout.Label("About", EditorStyles.boldLabel);
using (new GUILayout.VerticalScope(EditorStyles.helpBox))
using (new GUILayout.VerticalScope(Styles.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.
GUILayout.Label("Gameplay Ingredients", Styles.centeredTitle);
GUILayout.Label(@"Simple, Organic, Open Source
GameplayIngredients is a framework that comes with a variety of features : these can be configured in a <b>GameplayIngredientsSettings</b> asset.
A set of Runtime and Editor Tools for your unity prototypes and games. Released under MIT License as a unity package.
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);
This package also makes use of the following third party components:
* Naughty Attributes by Denis Rizov (https://github.com/dbrizov)
* Fugue Icons by Yusuke Kamiyamane (https://p.yusukekamiyamane.com/).
* Header art background 'Chef's Station' made by Todd Quackenbush, released on unspash.com (https://unsplash.com/photos/x5SRhkFajrA).
", Styles.centeredBody);
if (GUILayout.Button("Create GameplayIngredientsSettings Asset"))
{
GameplayIngredientsSettings asset = Instantiate<GameplayIngredientsSettings>(GameplayIngredientsSettings.defaultSettings);
AssetDatabase.CreateAsset(asset, "Assets/Resources/GameplayIngredientsSettings.asset");
Selection.activeObject = asset;
}
if (GUILayout.Button(" Github Page ", Styles.buttonLeft))
Application.OpenURL("https://github.com/peeweek/net.peeweek.gameplay-ingredients");
if (GUILayout.Button(" Report a Bug ", Styles.buttonMid))
Application.OpenURL("https://github.com/peeweek/net.peeweek.gameplay-ingredients/issues");
if (GUILayout.Button(" LICENSE ", Styles.buttonRight))
Application.OpenURL("https://github.com/peeweek/net.peeweek.gameplay-ingredients/blob/master/LICENSE");
GUILayout.FlexibleSpace();
void ConfigurationGUI()
{
GUILayout.Label("Configuration", EditorStyles.boldLabel);
GUILayout.FlexibleSpace();
}
struct Tip
{
public string Title;
public string Body;
}
static List<Tip> tips = new List<Tip>()
{
new Tip(){ Title = "Show Gizmos", Body = "You can toggle Gizmos on and off by using the Ctrl + , key shortcut."},
new Tip(){ Title = "Editor Scene Setups", Body = "You can save your current multi-scene setup to an asset by using the File/Save Current Scene Setup As... or create an Editor Scene Setup asset from the Project View. These assets can be double-clicked to restore all scenes at once."},
new Tip(){ Title = "Find And Replace", Body = "You can use the Find and Replace window to select, add, and/or refine list of objects in your scene based on different criteria (name, components, etc.). You can then turn this search result into a selection, or replace every object from this list by a prefab or a copy of another game object."},
new Tip(){ Title = "Game View Link", Body = "Game View link enables you to link your scene view and your game view. To enable it use Ctrl + . or click the 'Game' button in the additional Scene View toolbar. You can define a prefab (named LinkGameViewCamera) containing a camera to setup this camera (for instance if you use HD Render Pipeline and Postprocessing)"},
new Tip(){ Title = "Hierarchy Window Hints", Body = "You can toggle Hierarchy Window hints by selecting them in the Edit menu. These hints will display an icon for most common components on your game object."},
new Tip(){ Title = "Scene View POVs", Body = "Scene View POVs enable storing custom point of views in your scenes. To use it, select the POV dropdown in the additional custom toolbar."},
new Tip(){ Title = "Selection History", Body = "Selection History keeps track of your previously selected objects. You can also star/unstar objects in order to go back at them more easily"},
new Tip(){ Title = "Play From Here", Body = "Play From Here enables a custom callback when starting your Editor Play Session. Implement the callback and use the scene view camera position and forward vector to generate your custom start function."},
new Tip(){ Title = "Events, Logic and Actions", Body = "Gameplay Ingredients ships with many Actions, Logic and Events in order to set-up your scenes. Actions perform various actions on your scene objects, Logic trigger actions based on conditions, Events trigger Actions and Logic based on scene interaction (eg: On Trigger Enter)"},
new Tip(){ Title = "Managers", Body = "Managers are Monobehaviors that instantiate themselves automatically upon startup. You can define a []"},
};
}
static class Styles

public static GUIStyle buttonRight;
public static GUIStyle title;
public static GUIStyle body;
public static GUIStyle centeredTitle;
public static GUIStyle centeredBody;
public static GUIStyle helpBox;
static Styles()
{

title = new GUIStyle(EditorStyles.label);
title.fontSize = 22;
centeredTitle = new GUIStyle(title);
centeredTitle.alignment = TextAnchor.UpperCenter;
centeredBody = new GUIStyle(body);
centeredBody.alignment = TextAnchor.UpperCenter;
helpBox = new GUIStyle(EditorStyles.helpBox);
helpBox.padding = new RectOffset(12,12,12,12);
}
}
}

41
Editor/WelcomeScreen/WelcomeScreen.Setup.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace GameplayIngredients.Editor
{
partial class WelcomeScreen : EditorWindow
{
void OnSetupGUI()
{
GUILayout.Label("First Time Setup", EditorStyles.boldLabel);
using (new GUILayout.VerticalScope(Styles.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();
}
}
}
}

11
Editor/WelcomeScreen/WelcomeScreen.Setup.cs.meta


fileFormatVersion: 2
guid: 355e546690fd9c045816544642d9faa8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

69
Editor/WelcomeScreen/WelcomeScreen.Tips.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace GameplayIngredients.Editor
{
partial class WelcomeScreen : EditorWindow
{
int tipIndex = 0;
void InitTips()
{
tipIndex = Random.Range(0, tips.Count);
}
void OnTipsGUI()
{
GUILayout.Label("Tip of the Day", EditorStyles.boldLabel);
using (new GUILayout.VerticalScope(Styles.helpBox))
{
var tip = tips[tipIndex];
GUILayout.Label(tip.Title, Styles.title);
GUILayout.Space(12);
GUILayout.Label(tip.Body, Styles.body);
GUILayout.FlexibleSpace();
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("<<"))
{
tipIndex--;
if (tipIndex < 0)
tipIndex = tips.Count - 1;
}
if (GUILayout.Button(">>"))
{
tipIndex++;
if (tipIndex == tips.Count)
tipIndex = 0;
}
}
}
}
struct Tip
{
public string Title;
public string Body;
}
static List<Tip> tips = new List<Tip>()
{
#if UNITY_2018_3
new Tip(){ Title = "Show Gizmos", Body = "You can toggle Gizmos on and off by using the Ctrl + , key shortcut."},
#endif
new Tip(){ Title = "Editor Scene Setups", Body = "You can save your current multi-scene setup to an asset by using the File/Save Current Scene Setup As... or create an Editor Scene Setup asset from the Project View. These assets can be double-clicked to restore all scenes at once."},
new Tip(){ Title = "Find And Replace", Body = "You can use the Find and Replace window to select, add, and/or refine list of objects in your scene based on different criteria (name, components, etc.). You can then turn this search result into a selection, or replace every object from this list by a prefab or a copy of another game object."},
new Tip(){ Title = "Game View Link", Body = "Game View link enables you to link your scene view and your game view. To enable it use Ctrl + . or click the 'Game' button in the additional Scene View toolbar. You can define a prefab (named LinkGameViewCamera) containing a camera to setup this camera (for instance if you use HD Render Pipeline and Postprocessing)"},
new Tip(){ Title = "Hierarchy Window Hints", Body = "You can toggle Hierarchy Window hints by selecting them in the Edit menu. These hints will display an icon for most common components on your game object."},
new Tip(){ Title = "Scene View POVs", Body = "Scene View POVs enable storing custom point of views in your scenes. To use it, select the POV dropdown in the additional custom toolbar."},
new Tip(){ Title = "Selection History", Body = "Selection History keeps track of your previously selected objects. You can also star/unstar objects in order to go back at them more easily"},
new Tip(){ Title = "Play From Here", Body = "Play From Here enables a custom callback when starting your Editor Play Session. Implement the callback and use the scene view camera position and forward vector to generate your custom start function."},
new Tip(){ Title = "Events, Logic and Actions", Body = "Gameplay Ingredients ships with many Actions, Logic and Events in order to set-up your scenes. Actions perform various actions on your scene objects, Logic trigger actions based on conditions, Events trigger Actions and Logic based on scene interaction (eg: On Trigger Enter)"},
new Tip(){ Title = "Managers", Body = "Managers are Monobehaviors that instantiate themselves automatically upon startup. You can define a [ManagerDefaultPrefab]"},
};
}
}

11
Editor/WelcomeScreen/WelcomeScreen.Tips.cs.meta


fileFormatVersion: 2
guid: 53a69596a59d33047b38f348b727a44d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存