浏览代码

Base Commit

/main
Thomas Iché 5 年前
当前提交
7ce26a75
共有 6 个文件被更改,包括 167 次插入0 次删除
  1. 8
      Editor/NewSceneWindow.meta
  2. 108
      Editor/NewSceneWindow/NewSceneWindow.cs
  3. 11
      Editor/NewSceneWindow/NewSceneWindow.cs.meta
  4. 29
      Editor/NewSceneWindow/SceneTemplateList.cs
  5. 11
      Editor/NewSceneWindow/SceneTemplateList.cs.meta

8
Editor/NewSceneWindow.meta


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

108
Editor/NewSceneWindow/NewSceneWindow.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
namespace GameplayIngredients.Editor
{
public class NewSceneWindow : EditorWindow
{
const int WindowWidth = 640;
const int WindowHeight = 380;
[MenuItem("File/New Scene From Template... &%N", priority = 1)]
static void ShowNewSceneWindow()
{
GetWindow<NewSceneWindow>(true);
}
private void OnEnable()
{
titleContent = new GUIContent("New Scene From Template");
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);
ReloadList();
}
private void OnGUI()
{
GUILayout.Label("Available Templates");
using (new GUILayout.HorizontalScope(GUILayout.ExpandHeight(true)))
{
using (new GUILayout.VerticalScope(Styles.helpBox, GUILayout.Width(180)))
{
DrawTemplateList();
}
GUILayout.Space(8);
using (new GUILayout.VerticalScope(Styles.helpBox))
{
DrawTemplateDetails();
}
}
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
if(GUILayout.Button("Create"))
{
// Do Something
this.Close();
}
}
}
public static void ReloadList()
{
if (templateLists == null)
templateLists = new List<SceneTemplateList>();
else
templateLists.Clear();
string[] all = AssetDatabase.FindAssets("t:" + typeof(SceneTemplateList).Name);
foreach(var guid in all)
{
templateLists.Add(AssetDatabase.LoadAssetAtPath<SceneTemplateList>(AssetDatabase.GUIDToAssetPath(guid)));
}
}
static List<SceneTemplateList> templateLists;
Vector2 scrollList = Vector2.zero;
void DrawTemplateList()
{
GUILayout.BeginScrollView(scrollList);
GUILayout.FlexibleSpace();
GUILayout.EndScrollView();
}
void DrawTemplateDetails()
{
GUILayout.FlexibleSpace();
}
static class Styles
{
public static GUIStyle buttonLeft;
public static GUIStyle buttonMid;
public static GUIStyle buttonRight;
public static GUIStyle helpBox;
static Styles()
{
buttonLeft = new GUIStyle(EditorStyles.miniButtonLeft);
buttonMid = new GUIStyle(EditorStyles.miniButtonMid);
buttonRight = new GUIStyle(EditorStyles.miniButtonRight);
buttonLeft.fontSize = 12;
buttonMid.fontSize = 12;
buttonRight.fontSize = 12;
helpBox = new GUIStyle(EditorStyles.helpBox);
helpBox.padding = new RectOffset(12, 12, 12, 12);
}
}
}
}

11
Editor/NewSceneWindow/NewSceneWindow.cs.meta


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

29
Editor/NewSceneWindow/SceneTemplateList.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace GameplayIngredients.Editor
{
public class SceneTemplateList : ScriptableObject
{
[MenuItem("Assets/Create/Scene Template List", priority = 201)]
static void CreateSceneTemplateListAsset()
{
AssetFactory.CreateAssetInProjectWindow<SceneTemplateList>("", "New SceneTemplateList.asset");
}
public string ListName = "New Template List";
public SceneWindowTemplate[] Templates;
}
[System.Serializable]
public struct SceneWindowTemplate
{
public string Name;
[Multiline]
public string Description;
[NonNullCheck]
public SceneAsset Scene;
}
}

11
Editor/NewSceneWindow/SceneTemplateList.cs.meta


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