Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

138 行
5.9 KiB

using System;
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))
{
pages[currentPage].Invoke();
GUILayout.FlexibleSpace();
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
EditorGUI.BeginDisabledGroup(currentPage == 0);
if (GUILayout.Button("Back"))
{
currentPage--;
}
EditorGUI.EndDisabledGroup();
EditorGUI.BeginDisabledGroup(currentPage == pages.Length - 1);
if (GUILayout.Button("Next"))
{
currentPage++;
}
EditorGUI.EndDisabledGroup();
}
}
}
public int currentPage = 0;
public Action[] pages = new Action[]
{
WelcomePage, SettingAssetPage,
#if ENABLE_INPUT_SYSTEM
InputSystemPage,
#endif
UnpackPackagePage
};
static void WelcomePage()
{
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.", Styles.body);
}
static void InputSystemPage()
{
GUILayout.Label("Input System package detected", Styles.title);
GUILayout.Space(12);
GUILayout.Label(@"It seems that you have the Input System configured for your project. In order to make it work with the UI Event Manager, we can create a configured prefab for you.", Styles.body);
GUILayout.Space(12);
if (GUILayout.Button("Create/Replace", GUILayout.Width(180), GUILayout.Height(32)))
{
if(AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Resources/UIEventManager.prefab") == null
|| EditorUtility.DisplayDialog("Prefab already present", "UIEventManager already exists, overwrite?", "Yes", "No"))
{
var go = UIEventManager.CreateManagerObject();
var prefab = PrefabUtility.SaveAsPrefabAsset(go, "Assets/Resources/UIEventManager.prefab");
DestroyImmediate(go);
Selection.activeObject = prefab;
}
}
}
public const string kSettingsAssetPath = "Assets/Resources/GameplayIngredientsSettings.asset";
static void SettingAssetPage()
{
GUILayout.Label("Creating a Settings Asset", Styles.title);
GUILayout.Space(12);
GUILayout.Label(@"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 for your project's needs.
", Styles.body);
GUILayout.Space(16);
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if (GUILayout.Button("Create GameplayIngredientsSettings Asset"))
{
bool create = true;
if(System.IO.File.Exists(Application.dataPath +"/../"+ kSettingsAssetPath))
{
if (!EditorUtility.DisplayDialog("GameplayIngredientsSettings Asset Overwrite", "A GameplayIngredientsSettings Asset already exists, do you want to overwrite it?", "Yes", "No"))
create = false;
}
if(create)
{
if(!System.IO.Directory.Exists(Application.dataPath+"/Resources"))
AssetDatabase.CreateFolder("Assets", "Resources");
GameplayIngredientsSettings asset = Instantiate<GameplayIngredientsSettings>(GameplayIngredientsSettings.defaultSettings);
AssetDatabase.CreateAsset(asset, kSettingsAssetPath);
Selection.activeObject = asset;
}
}
}
}
static void UnpackPackagePage()
{
GUILayout.Label("Unpacking Starter Content", Styles.title);
GUILayout.Space(12);
GUILayout.Label(@"In order to customize your project, you can create default assets that you will be able to customize.
Please select a package depending on your project's render loop. If you do not know about render loops, you will probably need to install the Built-in Renderer Package.", Styles.body);
GUILayout.Space(16);
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
using (new GUILayout.VerticalScope())
{
if (GUILayout.Button("Built-in Renderer"))
AssetDatabase.ImportPackage("Packages/net.peeweek.gameplay-ingredients/StarterAssets/GameplayIngredients-Starter-BuiltInRenderer.unitypackage", false);
if (GUILayout.Button("HD Render Pipeline"))
AssetDatabase.ImportPackage("Packages/net.peeweek.gameplay-ingredients/StarterAssets/GameplayIngredients-Starter-HDRP.unitypackage", false);
if (GUILayout.Button("Universal Render Pipeline"))
AssetDatabase.ImportPackage("Packages/net.peeweek.gameplay-ingredients/StarterAssets/GameplayIngredients-Starter-URP.unitypackage", false);
}
}
}
}
}