Initial commit
This commit is contained in:
1 parent
ee9615239e
commit
16feac691f
4093 files changed
+1030491
No files matched your search
+131
@@ -0,0 +1,131 @@
|
||||
using PWCommon4;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
//This class is not a full editor class by itself, but used to collect reusable methods
|
||||
//for editing Stamper Auto Mask Exporters in a reorderable list.
|
||||
public class StamperAutoMaskExportListEditor : PWEditor, IPWEditor
|
||||
{
|
||||
|
||||
public static float OnElementHeight()
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
public static List<AutoMaskExport> OnRemoveListEntry(List<AutoMaskExport> oldList, int index)
|
||||
{
|
||||
oldList.RemoveAt(index);
|
||||
return oldList;
|
||||
}
|
||||
|
||||
public static List<AutoMaskExport> OnAddListEntry(List<AutoMaskExport> oldList)
|
||||
{
|
||||
oldList.Add(new AutoMaskExport { isActive=true });
|
||||
return oldList;
|
||||
}
|
||||
|
||||
public static bool DrawListHeader(Rect rect, bool currentFoldOutState, bool currentToggleAllState, List<AutoMaskExport> autoMaskList, EditorUtils editorUtils, ref GaiaConstants.AutoSpawnerArea autoSpawnerArea)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
//rect.xMin += 0f;
|
||||
|
||||
|
||||
Rect dropdownRect = new Rect(rect);
|
||||
dropdownRect.width = 50;
|
||||
dropdownRect.height = 15;
|
||||
dropdownRect.y += 2;
|
||||
dropdownRect.x = rect.x + rect.width - 2 - dropdownRect.width;
|
||||
|
||||
GUIStyle dropdownStyle = new GUIStyle(GUI.skin.button);
|
||||
dropdownStyle.fixedHeight = 15;
|
||||
|
||||
Rect label2Rect = new Rect(rect);
|
||||
label2Rect.width = 30;
|
||||
label2Rect.x = dropdownRect.x - 5 - label2Rect.width;
|
||||
|
||||
|
||||
Rect label1Rect = new Rect(rect);
|
||||
label1Rect.x += 35;
|
||||
label1Rect.width = rect.width - label2Rect.width - 35 - dropdownRect.width - 5 - 10;
|
||||
|
||||
|
||||
Rect toggleAllRect = new Rect(rect);
|
||||
toggleAllRect.x += 15;
|
||||
toggleAllRect.width = 12;
|
||||
|
||||
bool oldToggleOldState = currentToggleAllState;
|
||||
currentToggleAllState = EditorGUI.Toggle(toggleAllRect, currentToggleAllState);
|
||||
EditorGUI.LabelField(toggleAllRect, editorUtils.GetContent("AutoToggleAllTooltip"));
|
||||
|
||||
if (currentToggleAllState != oldToggleOldState)
|
||||
{
|
||||
foreach (AutoMaskExport entry in autoMaskList)
|
||||
{
|
||||
entry.isActive = currentToggleAllState;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.LabelField(label1Rect, editorUtils.GetContent("AutoMaskMapExportHeader"));
|
||||
EditorGUI.LabelField(label2Rect, editorUtils.GetContent("AutoMaskMapExportAreaLabel"));
|
||||
|
||||
autoSpawnerArea = (GaiaConstants.AutoSpawnerArea)EditorGUI.EnumPopup(dropdownRect, autoSpawnerArea, dropdownStyle);
|
||||
EditorGUI.LabelField(dropdownRect, editorUtils.GetContent("AutoMaskMapExportAreaTooltip"));
|
||||
|
||||
//bool newFoldOutState = EditorGUI.Foldout(rect, currentFoldOutState, PropertyCount("SpawnerAdded", spawnerList, editorUtils), true);
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
//return newFoldOutState;
|
||||
|
||||
|
||||
return currentToggleAllState;
|
||||
}
|
||||
|
||||
public static void DrawList(ReorderableList list, EditorUtils editorUtils)
|
||||
{
|
||||
Rect maskRect;
|
||||
maskRect = EditorGUILayout.GetControlRect(true, list.GetHeight());
|
||||
list.DoList(maskRect);
|
||||
}
|
||||
|
||||
public static void DrawListElement(Rect rect, ref AutoMaskExport listEntry, EditorUtils m_editorUtils)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
//EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width * 0.1f, EditorGUIUtility.singleLineHeight), m_editorUtils.GetContent("AutoSpawnerActive"));
|
||||
listEntry.isActive = EditorGUI.Toggle(new Rect(rect.x, rect.y, 20, EditorGUIUtility.singleLineHeight), listEntry.isActive);
|
||||
//switch (listEntry.status)
|
||||
//{
|
||||
// case AutoSpawnerStatus.Spawning:
|
||||
// EditorGUI.LabelField(new Rect(rect.x + rect.width * 0.2f, rect.y, rect.width * 0.2f, EditorGUIUtility.singleLineHeight), String.Format("{0:f0}", listEntry.spawner.m_spawnProgress * 100));
|
||||
// break;
|
||||
// default:
|
||||
// EditorGUI.LabelField(new Rect(rect.x + rect.width * 0.2f, rect.y, rect.width * 0.2f, EditorGUIUtility.singleLineHeight), listEntry.status.ToString());
|
||||
// break;
|
||||
//}
|
||||
bool currentGUIState = GUI.enabled;
|
||||
GUI.enabled = listEntry.isActive;
|
||||
#if GAIA_PRO_PRESENT
|
||||
listEntry.maskMapExport = (MaskMapExport)EditorGUI.ObjectField(new Rect(rect.x + 20, rect.y, rect.width - 20, EditorGUIUtility.singleLineHeight), listEntry.maskMapExport, typeof(MaskMapExport), true);
|
||||
#endif
|
||||
GUI.enabled = currentGUIState;
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static GUIContent PropertyCount(string key, List<AutoMaskExport> list, EditorUtils editorUtils)
|
||||
{
|
||||
GUIContent content = editorUtils.GetContent(key);
|
||||
content.text += " [" + list.Count + "]";
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 610f3026297b7cf4d99a80c4a697d913
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
using PWCommon4;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
//This class is not a full editor class by itself, but used to collect reusable methods
|
||||
//for editing Stamper Auto Spawners in a reorderable list.
|
||||
public class StamperAutoSpawnerListEditor : PWEditor, IPWEditor
|
||||
{
|
||||
|
||||
public static float OnElementHeight()
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
public static List<AutoSpawner> OnRemoveListEntry(List<AutoSpawner> oldList, int index)
|
||||
{
|
||||
//if (index < 0 || index >= oldList.Length)
|
||||
// return null;
|
||||
//SpawnerPresetListEntry toRemove = oldList[index];
|
||||
//SpawnerPresetListEntry[] newList = new SpawnerPresetListEntry[oldList.Length - 1];
|
||||
//for (int i = 0; i < newList.Length; ++i)
|
||||
//{
|
||||
// if (i < index)
|
||||
// {
|
||||
// newList[i] = oldList[i];
|
||||
// }
|
||||
// else if (i >= index)
|
||||
// {
|
||||
// newList[i] = oldList[i + 1];
|
||||
// }
|
||||
//}
|
||||
oldList.RemoveAt(index);
|
||||
return oldList;
|
||||
}
|
||||
|
||||
public static List<AutoSpawner> OnAddListEntry(List<AutoSpawner> oldList)
|
||||
{
|
||||
oldList.Add(new AutoSpawner() { isActive = true, status= AutoSpawnerStatus.Initial });
|
||||
return oldList;
|
||||
}
|
||||
|
||||
public static bool DrawListHeader(Rect rect, bool currentFoldOutState, bool currentToggleAllState, List<AutoSpawner> spawnerList, EditorUtils editorUtils, ref GaiaConstants.AutoSpawnerArea autoSpawnerArea)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
//rect.xMin += 0f;
|
||||
|
||||
|
||||
Rect dropdownRect = new Rect(rect);
|
||||
dropdownRect.width = 50;
|
||||
dropdownRect.height = 15;
|
||||
dropdownRect.y += 2;
|
||||
dropdownRect.x = rect.x + rect.width - 2- dropdownRect.width;
|
||||
|
||||
GUIStyle dropdownStyle = new GUIStyle(GUI.skin.button);
|
||||
dropdownStyle.fixedHeight = 15;
|
||||
|
||||
Rect label2Rect = new Rect(rect);
|
||||
label2Rect.width = 30;
|
||||
label2Rect.x = dropdownRect.x - 5 - label2Rect.width;
|
||||
|
||||
|
||||
Rect label1Rect = new Rect(rect);
|
||||
label1Rect.x += 35;
|
||||
label1Rect.width = rect.width - label2Rect.width - 35 - dropdownRect.width - 5 - 10;
|
||||
|
||||
|
||||
Rect toggleAllRect = new Rect(rect);
|
||||
toggleAllRect.x += 15;
|
||||
toggleAllRect.width = 12;
|
||||
|
||||
bool oldToggleOldState = currentToggleAllState;
|
||||
currentToggleAllState = EditorGUI.Toggle(toggleAllRect, currentToggleAllState);
|
||||
EditorGUI.LabelField(toggleAllRect, editorUtils.GetContent("AutoToggleAllTooltip"));
|
||||
|
||||
if (currentToggleAllState != oldToggleOldState)
|
||||
{
|
||||
foreach (AutoSpawner entry in spawnerList)
|
||||
{
|
||||
entry.isActive = currentToggleAllState;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.LabelField(label1Rect, editorUtils.GetContent("AutoSpawnerHeader"));
|
||||
EditorGUI.LabelField(label2Rect, editorUtils.GetContent("AutoSpawnerAreaLabel"));
|
||||
|
||||
autoSpawnerArea = (GaiaConstants.AutoSpawnerArea)EditorGUI.EnumPopup(dropdownRect, autoSpawnerArea, dropdownStyle);
|
||||
EditorGUI.LabelField(dropdownRect, editorUtils.GetContent("AutoSpawnerAreaTooltip"));
|
||||
|
||||
//bool newFoldOutState = EditorGUI.Foldout(rect, currentFoldOutState, PropertyCount("SpawnerAdded", spawnerList, editorUtils), true);
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
//return newFoldOutState;
|
||||
|
||||
|
||||
return currentToggleAllState;
|
||||
}
|
||||
|
||||
public static void DrawList(ReorderableList list, EditorUtils editorUtils)
|
||||
{
|
||||
Rect maskRect;
|
||||
//if (listExpanded)
|
||||
//{
|
||||
maskRect = EditorGUILayout.GetControlRect(true, list.GetHeight());
|
||||
list.DoList(maskRect);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// int oldIndent = EditorGUI.indentLevel;
|
||||
// EditorGUI.indentLevel = 1;
|
||||
// listExpanded = EditorGUILayout.Foldout(listExpanded, PropertyCount("SpawnerAdded", (List<SpawnerPresetListEntry>)list.list, editorUtils), true);
|
||||
// maskRect = GUILayoutUtility.GetLastRect();
|
||||
// EditorGUI.indentLevel = oldIndent;
|
||||
//}
|
||||
|
||||
//editorUtils.Panel("MaskBaking", DrawMaskBaking, false);
|
||||
}
|
||||
|
||||
public static void DrawListElement(Rect rect, AutoSpawner listEntry, ref bool changesMade)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
//EditorGUI.LabelField(new Rect(rect.x, rect.y, rect.width * 0.1f, EditorGUIUtility.singleLineHeight), m_editorUtils.GetContent("AutoSpawnerActive"));
|
||||
EditorGUI.BeginChangeCheck();
|
||||
listEntry.isActive = EditorGUI.Toggle(new Rect(rect.x, rect.y, 20, EditorGUIUtility.singleLineHeight), listEntry.isActive);
|
||||
//switch (listEntry.status)
|
||||
//{
|
||||
// case AutoSpawnerStatus.Spawning:
|
||||
// EditorGUI.LabelField(new Rect(rect.x + rect.width * 0.2f, rect.y, rect.width * 0.2f, EditorGUIUtility.singleLineHeight), String.Format("{0:f0}", listEntry.spawner.m_spawnProgress * 100));
|
||||
// break;
|
||||
// default:
|
||||
// EditorGUI.LabelField(new Rect(rect.x + rect.width * 0.2f, rect.y, rect.width * 0.2f, EditorGUIUtility.singleLineHeight), listEntry.status.ToString());
|
||||
// break;
|
||||
//}
|
||||
bool currentGUIState = GUI.enabled;
|
||||
GUI.enabled = listEntry.isActive;
|
||||
listEntry.spawner = (Spawner)EditorGUI.ObjectField(new Rect(rect.x + 20, rect.y, rect.width - 20, EditorGUIUtility.singleLineHeight), listEntry.spawner, typeof(Spawner), true);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
changesMade = true;
|
||||
}
|
||||
GUI.enabled = currentGUIState;
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static GUIContent PropertyCount(string key, List<AutoSpawner> list, EditorUtils editorUtils)
|
||||
{
|
||||
GUIContent content = editorUtils.GetContent(key);
|
||||
content.text += " [" + list.Count + "]";
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d6633d4a76ffff4195b07958f018135
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,300 @@
|
||||
// Copyright © 2018 Procedural Worlds Pty Limited. All Rights Reserved.
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.AnimatedValues;
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
|
||||
/*
|
||||
* Custom Editor for Sequence assets
|
||||
*/
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
//[CustomPropertyDrawer(typeof(StamperSettings.ClipData))]
|
||||
//public class StamperSettingsClipDataEditor : PropertyDrawer
|
||||
//{
|
||||
// public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
// {
|
||||
// return EditorGUIUtility.singleLineHeight;
|
||||
// }
|
||||
// public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
// {
|
||||
// position.width -= 120f;
|
||||
// SerializedProperty clip = property.FindPropertyRelative("m_clip");
|
||||
// SerializedProperty volume = property.FindPropertyRelative("m_volume");
|
||||
// EditorGUI.ObjectField(position, clip, GUIContent.none);
|
||||
// position.xMin = position.xMax;
|
||||
// position.xMax += 120f;
|
||||
// EditorGUI.Slider(position, volume, 0f, 1f, GUIContent.none);
|
||||
// }
|
||||
//}
|
||||
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(StamperSettings))]
|
||||
public class StamperSettingsEditor : PWEditor, IPWEditor
|
||||
{
|
||||
/// <summary> Reference to EditorUtils for GUI functions </summary>
|
||||
private EditorUtils m_editorUtils;
|
||||
|
||||
//Properties of Sequence asset
|
||||
SerializedProperty m_requirements;
|
||||
SerializedProperty m_clipData;
|
||||
SerializedProperty m_volume;
|
||||
SerializedProperty m_playbackSpeed;
|
||||
SerializedProperty m_randomizeOrder;
|
||||
SerializedProperty m_crossFade;
|
||||
SerializedProperty m_trackFadeTime;
|
||||
SerializedProperty m_volumeFadeTime;
|
||||
SerializedProperty m_playbackSpeedFadeTime;
|
||||
SerializedProperty m_delayChance;
|
||||
SerializedProperty m_delayFadeTime;
|
||||
SerializedProperty m_minMaxDelay;
|
||||
SerializedProperty m_valuesMix;
|
||||
SerializedProperty m_values;
|
||||
SerializedProperty m_eventsMix;
|
||||
SerializedProperty m_events;
|
||||
SerializedProperty m_randomVolume;
|
||||
SerializedProperty m_minMaxVolume;
|
||||
SerializedProperty m_randomPlaybackSpeed;
|
||||
SerializedProperty m_minMaxPlaybackSpeed;
|
||||
SerializedProperty m_modifiers;
|
||||
SerializedProperty m_outputType;
|
||||
SerializedProperty m_outputPrefab;
|
||||
SerializedProperty m_outputDirect;
|
||||
SerializedProperty m_outputDistance;
|
||||
SerializedProperty m_outputVerticalAngle;
|
||||
SerializedProperty m_outputHorizontalAngle;
|
||||
SerializedProperty m_syncGroup;
|
||||
SerializedProperty m_syncType;
|
||||
SerializedProperty m_eventsWhilePlaying;
|
||||
//SerializedProperty m_outputFollowPosition = null;
|
||||
//SerializedProperty m_outputFollowRotation = null;
|
||||
//SerializedProperty m_OnPlayClip = null;
|
||||
//SerializedProperty m_OnStopClip = null;
|
||||
|
||||
/// <summary> Animated Boolean for if Output Distance should be shown </summary>
|
||||
AnimBool outputGroup;
|
||||
/// <summary> Animated Boolean for if Sliders should be displayed </summary>
|
||||
AnimBool slidersGroup;
|
||||
/// <summary> Animated Boolean for if Events should be displayed </summary>
|
||||
AnimBool eventsGroup;
|
||||
/// <summary> Animated Boolean for if OutputDirect is true </summary>
|
||||
AnimBool directGroup;
|
||||
/// <summary> Animated Boolean for if we are in a SyncGroup </summary>
|
||||
AnimBool syncGroup;
|
||||
UnityEditorInternal.ReorderableList m_eventsReorderable;
|
||||
UnityEditorInternal.ReorderableList m_valuesReorderable;
|
||||
bool m_clipsExpanded = true;
|
||||
UnityEditorInternal.ReorderableList m_clipsReorderable;
|
||||
|
||||
UnityEditorInternal.ReorderableList m_modifiersReorderable;
|
||||
UnityEditorInternal.ReorderableList m_eventsWhilePlayingReorderable;
|
||||
|
||||
/// <summary> Destructor to release references </summary>
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (m_editorUtils != null)
|
||||
{
|
||||
m_editorUtils.Dispose();
|
||||
}
|
||||
}
|
||||
/// <summary> Constructor to set up references for editor </summary>
|
||||
void OnEnable()
|
||||
{
|
||||
m_clipData = serializedObject.FindProperty("m_clipData");
|
||||
m_volume = serializedObject.FindProperty("m_volume");
|
||||
m_playbackSpeed = serializedObject.FindProperty("m_playbackSpeed");
|
||||
m_randomizeOrder = serializedObject.FindProperty("m_randomizeOrder");
|
||||
m_crossFade = serializedObject.FindProperty("m_crossFade");
|
||||
m_trackFadeTime = serializedObject.FindProperty("m_trackFadeTime");
|
||||
m_volumeFadeTime = serializedObject.FindProperty("m_volumeFadeTime");
|
||||
m_playbackSpeedFadeTime = serializedObject.FindProperty("m_playbackSpeedFadeTime");
|
||||
|
||||
m_clipsReorderable = new UnityEditorInternal.ReorderableList(serializedObject, m_clipData, true, false, true, true);
|
||||
m_clipsReorderable.elementHeight = EditorGUIUtility.singleLineHeight;
|
||||
m_clipsReorderable.drawElementCallback = DrawClipElement;
|
||||
m_clipsReorderable.drawHeaderCallback = DrawClipHeader;
|
||||
m_clipsReorderable.onAddCallback = OnAddClip;
|
||||
|
||||
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
}
|
||||
|
||||
void OnAddClip(UnityEditorInternal.ReorderableList list)
|
||||
{
|
||||
int idx = m_clipData.arraySize;
|
||||
m_clipData.InsertArrayElementAtIndex(idx);
|
||||
if (idx == 0)
|
||||
m_clipData.GetArrayElementAtIndex(idx).FindPropertyRelative("m_volume").floatValue = 1f;
|
||||
}
|
||||
void DrawClipElement(Rect rect, int index, bool isActive, bool isFocused)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
EditorGUI.PropertyField(rect, m_clipData.GetArrayElementAtIndex(index), GUIContent.none);
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
}
|
||||
void DrawClipHeader(Rect rect)
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 0;
|
||||
rect.xMin += 8f;
|
||||
m_clipsExpanded = EditorGUI.Foldout(rect, m_clipsExpanded, PropertyCount("mClips", m_clipData), true);
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
}
|
||||
|
||||
/// <summary> Main GUI Function </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
// serializedObject.Update();
|
||||
|
||||
// m_editorUtils.Initialize(); // Do not remove this!
|
||||
// m_editorUtils.GUIHeader();
|
||||
// m_editorUtils.TitleNonLocalized(m_editorUtils.GetContent("SequenceDataHeader").text + serializedObject.targetObject.name);
|
||||
|
||||
// m_editorUtils.Panel("ClipsPanel", ClipsPanel, true);
|
||||
|
||||
// //m_editorUtils.GUIFooter();
|
||||
// serializedObject.ApplyModifiedProperties();
|
||||
//}
|
||||
}
|
||||
/// <summary> Panel to show "Clip" options of Sequence </summary>
|
||||
/// <param name="inlineHelp">Should help be displayed?</param>
|
||||
public void ClipsPanel(bool inlineHelp)
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
Rect clipsRect;
|
||||
if (m_clipsExpanded)
|
||||
{
|
||||
clipsRect = EditorGUILayout.GetControlRect(true, m_clipsReorderable.GetHeight());
|
||||
m_clipsReorderable.DoList(clipsRect);
|
||||
}
|
||||
else
|
||||
{
|
||||
int oldIndent = EditorGUI.indentLevel;
|
||||
EditorGUI.indentLevel = 1;
|
||||
m_clipsExpanded = EditorGUILayout.Foldout(m_clipsExpanded, PropertyCount("mClips", m_clipData), true);
|
||||
clipsRect = GUILayoutUtility.GetLastRect();
|
||||
EditorGUI.indentLevel = oldIndent;
|
||||
}
|
||||
if (Event.current.type == EventType.DragUpdated)
|
||||
{
|
||||
bool isValid = false;
|
||||
for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
|
||||
if (DragAndDrop.objectReferences[i] is AudioClip)
|
||||
{
|
||||
isValid = true;
|
||||
break;
|
||||
}
|
||||
if (isValid)
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Link;
|
||||
else
|
||||
DragAndDrop.visualMode = DragAndDropVisualMode.Rejected;
|
||||
}
|
||||
else if (Event.current.type == EventType.DragPerform)
|
||||
{
|
||||
for (int i = 0; i < DragAndDrop.objectReferences.Length; ++i)
|
||||
{
|
||||
if (!(DragAndDrop.objectReferences[i] is AudioClip))
|
||||
continue;
|
||||
int idx = m_clipData.arraySize;
|
||||
m_clipData.InsertArrayElementAtIndex(idx);
|
||||
SerializedProperty clipData = m_clipData.GetArrayElementAtIndex(idx);
|
||||
clipData.FindPropertyRelative("m_volume").floatValue = 1f;
|
||||
clipData.FindPropertyRelative("m_clip").objectReferenceValue = DragAndDrop.objectReferences[i];
|
||||
}
|
||||
Event.current.Use();
|
||||
}
|
||||
|
||||
m_editorUtils.InlineHelp("mClips", inlineHelp);
|
||||
//PropertyCountField("mClips", true, m_clips, ((Sequence)target).m_clips.Length, inlineHelp);
|
||||
//int badClipCount = 0;
|
||||
//for (int x = 0; x < m_clipData.arraySize; ++x)
|
||||
//{
|
||||
// AudioClip clip = m_clipData.GetArrayElementAtIndex(x).FindPropertyRelative("m_clip").objectReferenceValue as AudioClip;
|
||||
// if (clip != null)
|
||||
// {
|
||||
// if (clip.loadType != AudioClipLoadType.DecompressOnLoad)
|
||||
// {
|
||||
// ++badClipCount;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//if (badClipCount > 0)
|
||||
//{
|
||||
// EditorGUILayout.HelpBox(m_editorUtils.GetContent("InvalidClipMessage").text, MessageType.Warning, true);
|
||||
// if (m_editorUtils.ButtonRight("InvalidClipButton"))
|
||||
// {
|
||||
// GUIContent progressBarContent = m_editorUtils.GetContent("InvalidClipPopup");
|
||||
// for (int x = 0; x < m_clipData.arraySize; ++x)
|
||||
// {
|
||||
// AudioClip clip = m_clipData.GetArrayElementAtIndex(x).FindPropertyRelative("m_clip").objectReferenceValue as AudioClip;
|
||||
// EditorUtility.DisplayProgressBar(progressBarContent.text, progressBarContent.tooltip + clip.name, x / (float)badClipCount);
|
||||
// if (clip != null)
|
||||
// {
|
||||
// if (clip.loadType != AudioClipLoadType.DecompressOnLoad)
|
||||
// {
|
||||
// AudioImporter importer = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(clip)) as AudioImporter;
|
||||
// AudioImporterSampleSettings sampleSettings = importer.defaultSampleSettings;
|
||||
// sampleSettings.loadType = AudioClipLoadType.DecompressOnLoad;
|
||||
// importer.defaultSampleSettings = sampleSettings;
|
||||
// if (importer.ContainsSampleSettingsOverride("Standalone"))
|
||||
// {
|
||||
// sampleSettings = importer.GetOverrideSampleSettings("Standalone");
|
||||
// sampleSettings.loadType = AudioClipLoadType.DecompressOnLoad;
|
||||
// importer.SetOverrideSampleSettings("Standalone", sampleSettings);
|
||||
// }
|
||||
// importer.SaveAndReimport();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// EditorUtility.ClearProgressBar();
|
||||
// }
|
||||
//}
|
||||
|
||||
//m_editorUtils.PropertyField("mTrackFadeTime", m_trackFadeTime, inlineHelp);
|
||||
//if (m_trackFadeTime.floatValue < 0f)
|
||||
// m_trackFadeTime.floatValue = 0f;
|
||||
//m_editorUtils.PropertyField("mVolume", m_volume, inlineHelp);
|
||||
//m_editorUtils.PropertyField("mVolumeFadeTime", m_volumeFadeTime, inlineHelp);
|
||||
//if (m_volumeFadeTime.floatValue < 0f)
|
||||
// m_volumeFadeTime.floatValue = 0f;
|
||||
////EditorGUI.BeginDisabledGroup(syncGroup.target && ((SyncType)System.Enum.GetValues(typeof(SyncType)).GetValue(m_syncType.enumValueIndex) & SyncType.FIT) > 0);
|
||||
////{
|
||||
//// m_editorUtils.PropertyField("mPlaybackSpeed", m_playbackSpeed, inlineHelp);
|
||||
//// if (m_playbackSpeed.floatValue < 0f)
|
||||
//// m_playbackSpeed.floatValue = 0f;
|
||||
////}
|
||||
////EditorGUI.EndDisabledGroup();
|
||||
//EditorGUI.BeginDisabledGroup(syncGroup.target);
|
||||
//{
|
||||
// m_editorUtils.PropertyField("mPlaybackSpeedFadeTime", m_playbackSpeedFadeTime, inlineHelp);
|
||||
// if (m_playbackSpeedFadeTime.floatValue < 0f)
|
||||
// m_playbackSpeedFadeTime.floatValue = 0f;
|
||||
// m_editorUtils.PropertyField("mCrossFade", m_crossFade, inlineHelp);
|
||||
// if (m_crossFade.floatValue < 0f)
|
||||
// m_crossFade.floatValue = 0f;
|
||||
//}
|
||||
//EditorGUI.EndDisabledGroup();
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
/// <summary> Panel to display Output options </summary>
|
||||
/// <param name="inlineHelp">Should help be displayed?</param>
|
||||
|
||||
|
||||
private GUIContent PropertyCount(string key, SerializedProperty property)
|
||||
{
|
||||
GUIContent content = m_editorUtils.GetContent(key);
|
||||
content.text += " [" + property.arraySize + "]";
|
||||
return content;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c1325bdc2ae35d4283337daec61b386
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,114 @@
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Editor for Biome Preset settings, only offers a text & a button to create the spawner in the scene
|
||||
/// If the user wants to edit or create new spawner settings, they can do so by saving a spawner settings file from a spawner directly.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(WorldMap))]
|
||||
public class WorldMapEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
WorldMap m_worldMap;
|
||||
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_worldMap = (WorldMap)target;
|
||||
//Init editor utils
|
||||
if (m_editorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
m_editorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
m_editorUtils.Initialize(); // Do not remove this!
|
||||
m_worldMap = (WorldMap)target;
|
||||
serializedObject.Update();
|
||||
|
||||
if (m_worldMap.m_worldMapTerrain == null)
|
||||
{
|
||||
m_editorUtils.Panel("CreateWorldMap", CreateWorldMap, true);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_editorUtils.Panel("CreateWorldMap", CreateWorldMap, false);
|
||||
m_editorUtils.Panel("EditWorldMap", DrawEditWorldMap, true);
|
||||
m_editorUtils.Panel("SyncHeightmap", DrawSyncHeightmap, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void CreateWorldMap(bool obj)
|
||||
{
|
||||
if (m_worldMap.m_worldMapTerrain == null)
|
||||
{
|
||||
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("TerrainMissing"), MessageType.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.HelpBox(m_editorUtils.GetTextValue("CreateTerrainInfo"), MessageType.Info);
|
||||
}
|
||||
m_worldMap.m_worldMapTileSize = (GaiaConstants.EnvironmentSize)m_editorUtils.EnumPopup("TileSize", m_worldMap.m_worldMapTileSize);
|
||||
m_worldMap.m_heightmapResolution = (GaiaConstants.HeightmapResolution)m_editorUtils.EnumPopup("HeightmapResolution", m_worldMap.m_heightmapResolution);
|
||||
if (m_editorUtils.ButtonAutoIndent("CreateTerrainButton"))
|
||||
{
|
||||
m_worldMap.CreateWorldMapTerrain();
|
||||
m_worldMap.LookAtWorldMap();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private void DrawEditWorldMap(bool obj)
|
||||
{
|
||||
if (m_editorUtils.Button("RandomTerrainGeneration"))
|
||||
{
|
||||
WorldMap.ShowWorldMapStampSpawner();
|
||||
}
|
||||
//if (m_editorUtils.Button("DefineWorldMapMasks"))
|
||||
//{
|
||||
// WorldMap.ShowWorldBiomeMasksSpawner();
|
||||
//}
|
||||
if (m_editorUtils.Button("StampWorldMap"))
|
||||
{
|
||||
GameObject stamperObj = WorldMap.GetOrCreateWorldMapStamper();
|
||||
#if UNITY_EDITOR
|
||||
Selection.activeGameObject = stamperObj;
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void DrawSyncHeightmap(bool obj)
|
||||
{
|
||||
GUILayout.BeginVertical();
|
||||
if (m_editorUtils.Button("SyncWorldMapToTerrain"))
|
||||
{
|
||||
m_worldMap.SyncWorldMapToLocalMap();
|
||||
}
|
||||
if (m_editorUtils.Button("SyncTerrainToWorldMap"))
|
||||
{
|
||||
m_worldMap.SyncLocalMapToWorldMap();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06bf9c1cbdf1923499e25461bacf0e4f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
using Gaia.Internal;
|
||||
using PWCommon4;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Gaia
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Editor for Biome Preset settings, only offers a text & a button to create the spawner in the scene
|
||||
/// If the user wants to edit or create new spawner settings, they can do so by saving a spawner settings file from a spawner directly.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(WorldMapStampToken))]
|
||||
public class WorldMapStampTokenEditor : PWEditor
|
||||
{
|
||||
private EditorUtils m_editorUtils;
|
||||
WorldMapStampToken m_stampToken;
|
||||
|
||||
private GaiaSessionManager m_sessionManager;
|
||||
private GaiaSessionManager SessionManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_sessionManager == null)
|
||||
{
|
||||
m_sessionManager = GaiaSessionManager.GetSessionManager(false);
|
||||
}
|
||||
return m_sessionManager;
|
||||
}
|
||||
}
|
||||
|
||||
public EditorUtils EditorUtils { get => m_editorUtils; set => m_editorUtils = value; }
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_stampToken = (WorldMapStampToken)target;
|
||||
//Init editor utils
|
||||
if (EditorUtils == null)
|
||||
{
|
||||
// Get editor utils for this
|
||||
EditorUtils = PWApp.GetEditorUtils(this);
|
||||
}
|
||||
|
||||
m_stampToken.ReloadLocalStamper();
|
||||
m_stampToken.ReloadWorldStamper();
|
||||
|
||||
m_stampToken.m_isSelected = true;
|
||||
m_stampToken.UpdateGizmoPos();
|
||||
}
|
||||
private void OnDisable()
|
||||
{
|
||||
if (m_stampToken.m_syncedLocalStamper != null)
|
||||
{
|
||||
#if GAIA_PRO_PRESENT
|
||||
m_stampToken.m_syncedLocalStamper.TerrainLoader.m_isSelected = false;
|
||||
#endif
|
||||
}
|
||||
m_stampToken.m_isSelected = false;
|
||||
|
||||
if (m_stampToken.m_connectedStamperSettings != null)
|
||||
{
|
||||
m_stampToken.m_connectedStamperSettings.ClearImageMaskTextures();
|
||||
}
|
||||
m_stampToken.m_syncedLocalStamper.m_settings.ClearImageMaskTextures();
|
||||
m_stampToken.m_syncedLocalStamper.m_settings.ClearImageMaskTextures();
|
||||
}
|
||||
|
||||
private void OnSceneGUI()
|
||||
{
|
||||
if (m_stampToken.m_syncedLocalStamper != null)
|
||||
{
|
||||
Handles.BeginGUI();
|
||||
bool currentGUIState = GUI.enabled;
|
||||
if (!GaiaUtils.HasTerrains())
|
||||
{
|
||||
GUI.enabled = false;
|
||||
if (GUI.Button(new Rect(Screen.width - 275, Screen.height - 110, 250, 25), new GUIContent("Edit Stamp (Terrain not created yet!)","This Button allows you to edit the stamp on your actual terrain - it only becomes available after you export the terrain from the world designer.")))
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GUI.Button(new Rect(Screen.width - 275, Screen.height - 110, 250, 25), new GUIContent("Edit Stamp on Terrain", "This Button will close the world map view to edit the stamp on your actual terrain.")))
|
||||
{
|
||||
EditStamp();
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = currentGUIState;
|
||||
|
||||
if (GUI.Button(new Rect(Screen.width - 275, Screen.height - 75, 250, 25), new GUIContent("Return to World Designer","Closes the stamp preview to return to the World Designer.")))
|
||||
{
|
||||
TerrainLoaderManager.Instance.SwitchToWorldMap();
|
||||
GameObject worldmapObject = GaiaUtils.GetOrCreateWorldDesigner();
|
||||
Selection.activeObject = worldmapObject;
|
||||
}
|
||||
Handles.EndGUI();
|
||||
}
|
||||
|
||||
// dont render preview if this isnt a repaint. losing performance if we do
|
||||
if (Event.current.type != EventType.Repaint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Prefer to show the world map stamper
|
||||
if (TerrainLoaderManager.Instance.ShowWorldMapTerrain)
|
||||
{
|
||||
if (m_stampToken.m_syncedWorldMapStamper != null)
|
||||
{
|
||||
m_stampToken.SyncWorldMapStamper();
|
||||
m_stampToken.m_syncedWorldMapStamper.DrawStampPreview();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TerrainLoaderManager.Instance.ShowLocalTerrain)
|
||||
{
|
||||
if (m_stampToken.m_syncedLocalStamper != null)
|
||||
{
|
||||
m_stampToken.SyncLocalStamper(m_stampToken.m_syncedLocalStamper);
|
||||
m_stampToken.m_syncedLocalStamper.UpdateTerrainLoader();
|
||||
m_stampToken.m_syncedLocalStamper.DrawStampPreview();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void EditStamp()
|
||||
{
|
||||
TerrainLoaderManager.Instance.SwitchToLocalMap();
|
||||
if (GaiaUtils.HasDynamicLoadedTerrains())
|
||||
{
|
||||
Vector3Double origin = TerrainLoaderManager.Instance.GetOrigin();
|
||||
TerrainLoaderManager.Instance.SetOrigin(new Vector3Double(((m_stampToken.transform.position.x + origin.x) / TerrainLoaderManager.Instance.TerrainSceneStorage.m_worldMaprelativeSize) , 0, ((m_stampToken.transform.position.z+ origin.z) / TerrainLoaderManager.Instance.TerrainSceneStorage.m_worldMaprelativeSize)));
|
||||
//position the stamper at 0,Y,0 - we just shifted the origin to there, so we can set the stamper to origin.
|
||||
m_stampToken.m_syncedLocalStamper.transform.position = new Vector3(0f, m_stampToken.m_syncedLocalStamper.transform.position.y, 0f);
|
||||
m_stampToken.m_syncedLocalStamper.m_openedFromTerrainGenerator = true;
|
||||
}
|
||||
Selection.activeGameObject = m_stampToken.m_syncedLocalStamper.gameObject;
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorUtils.Initialize(); // Do not remove this!
|
||||
m_stampToken = (WorldMapStampToken)target;
|
||||
serializedObject.Update();
|
||||
m_stampToken.SyncLocationToStamperSettings();
|
||||
m_stampToken.UpdateGizmoPos();
|
||||
m_editorUtils.Panel("StamperControls", DrawStamperControls, true);
|
||||
}
|
||||
|
||||
private void DrawStamperControls(bool helpEnabled)
|
||||
{
|
||||
//m_stampToken.m_previewOnWorldMap = m_editorUtils.Toggle("PreviewOnWorldMap", m_stampToken.m_previewOnWorldMap, helpEnabled);
|
||||
//m_stampToken.m_previewOnLocalMap = m_editorUtils.Toggle("PreviewOnLocalMap", m_stampToken.m_previewOnLocalMap, helpEnabled);
|
||||
bool currentGUIState = GUI.enabled;
|
||||
|
||||
if (!GaiaUtils.HasTerrains())
|
||||
{
|
||||
GUI.enabled = false;
|
||||
m_editorUtils.ButtonAutoIndent("EditStampDisabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_editorUtils.ButtonAutoIndent("EditStamp"))
|
||||
{
|
||||
if (m_stampToken.m_syncedLocalStamper != null)
|
||||
{
|
||||
EditStamp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUI.enabled = currentGUIState;
|
||||
|
||||
if (m_editorUtils.ButtonAutoIndent("ReturnToGenerator"))
|
||||
{
|
||||
WorldMap.ShowWorldMapStampSpawner();
|
||||
}
|
||||
|
||||
if (m_stampToken.m_previewOnLocalMap && m_stampToken.m_syncedLocalStamper == null)
|
||||
{
|
||||
Stamper stamper = WorldMapStampToken.GetOrCreateSyncedStamper(GaiaConstants.worldMapLocalStamper);
|
||||
//load settings and don't instantiate - the stamper should be able to modify thses settings on the local map if the user wishes to!
|
||||
m_stampToken.LoadStamperSettings(stamper, false);
|
||||
m_stampToken.m_syncedLocalStamper = stamper;
|
||||
stamper.UpdateMinMaxHeight();
|
||||
stamper.m_stampDirty = true;
|
||||
}
|
||||
|
||||
if (m_stampToken.m_previewOnWorldMap && m_stampToken.m_syncedWorldMapStamper == null)
|
||||
{
|
||||
Stamper stamper = WorldMapStampToken.GetOrCreateSyncedStamper(GaiaConstants.worldMapWorldStamper);
|
||||
|
||||
//load settings and instantiate - the stamper should not modify the settings as it is just a scaled preview on the world map
|
||||
m_stampToken.LoadStamperSettings(stamper, true);
|
||||
//important - stamper must be marked as world map stamper to work with the world map terrain!
|
||||
stamper.m_settings.m_isWorldmapStamper = true;
|
||||
stamper.UpdateMinMaxHeight();
|
||||
stamper.m_stampDirty = true;
|
||||
m_stampToken.m_syncedWorldMapStamper = stamper;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e2b2f69cfa9acf4d96e58d7d8ccb09a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user