Merge remote-tracking branch 'origin/master' into gi
This commit is contained in:
@@ -221,6 +221,7 @@ void CookAssetsStep::CacheData::Load(CookingData& data)
|
||||
{
|
||||
const auto settings = WindowsPlatformSettings::Get();
|
||||
const bool modified =
|
||||
Settings.Windows.SupportDX12 != settings->SupportDX12 ||
|
||||
Settings.Windows.SupportDX11 != settings->SupportDX11 ||
|
||||
Settings.Windows.SupportDX10 != settings->SupportDX10 ||
|
||||
Settings.Windows.SupportVulkan != settings->SupportVulkan;
|
||||
@@ -1025,6 +1026,7 @@ bool CookAssetsStep::Perform(CookingData& data)
|
||||
#if PLATFORM_TOOLS_WINDOWS
|
||||
{
|
||||
const auto settings = WindowsPlatformSettings::Get();
|
||||
cache.Settings.Windows.SupportDX12 = settings->SupportDX12;
|
||||
cache.Settings.Windows.SupportDX11 = settings->SupportDX11;
|
||||
cache.Settings.Windows.SupportDX10 = settings->SupportDX10;
|
||||
cache.Settings.Windows.SupportVulkan = settings->SupportVulkan;
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
{
|
||||
struct
|
||||
{
|
||||
bool SupportDX12;
|
||||
bool SupportDX11;
|
||||
bool SupportDX10;
|
||||
bool SupportVulkan;
|
||||
|
||||
@@ -891,10 +891,10 @@ namespace FlaxEditor
|
||||
if (asset == null)
|
||||
throw new ArgumentNullException(nameof(asset));
|
||||
if (asset.WaitForLoaded())
|
||||
throw new FlaxException("Failed to load asset.");
|
||||
throw new Exception("Failed to load asset.");
|
||||
var source = Internal_GetShaderAssetSourceCode(FlaxEngine.Object.GetUnmanagedPtr(asset));
|
||||
if (source == null)
|
||||
throw new FlaxException("Failed to get source code.");
|
||||
throw new Exception("Failed to get source code.");
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
base.Initialize(layout);
|
||||
|
||||
var instance = (AnimEvent)Values[0];
|
||||
if (instance == null)
|
||||
return;
|
||||
var scriptType = TypeUtils.GetObjectType(instance);
|
||||
var editor = CustomEditorsUtil.CreateEditor(scriptType, false);
|
||||
layout.Object(Values, editor);
|
||||
@@ -125,6 +127,52 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
}
|
||||
}
|
||||
|
||||
internal void InitMissing(string typeName, byte[] data)
|
||||
{
|
||||
Type = ScriptType.Null;
|
||||
IsContinuous = false;
|
||||
CanDelete = true;
|
||||
CanSplit = false;
|
||||
CanResize = false;
|
||||
TooltipText = $"Missing Anim Event Type '{typeName}'";
|
||||
Instance = null;
|
||||
BackgroundColor = Color.Red;
|
||||
_instanceTypeName = typeName;
|
||||
_instanceData = data;
|
||||
}
|
||||
|
||||
internal void Load(BinaryReader stream)
|
||||
{
|
||||
StartFrame = (int)stream.ReadSingle();
|
||||
DurationFrames = (int)stream.ReadSingle();
|
||||
var typeName = stream.ReadStrAnsi(13);
|
||||
var type = TypeUtils.GetType(typeName);
|
||||
if (type == ScriptType.Null)
|
||||
{
|
||||
InitMissing(typeName, stream.ReadJsonBytes());
|
||||
return;
|
||||
}
|
||||
Init(type);
|
||||
stream.ReadJson(Instance);
|
||||
}
|
||||
|
||||
internal void Save(BinaryWriter stream)
|
||||
{
|
||||
stream.Write((float)StartFrame);
|
||||
stream.Write((float)DurationFrames);
|
||||
if (Type != ScriptType.Null)
|
||||
{
|
||||
stream.WriteStrAnsi(Type.TypeName, 13);
|
||||
stream.WriteJson(Instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Missing
|
||||
stream.WriteStrAnsi(_instanceTypeName, 13);
|
||||
stream.WriteJsonBytes(_instanceData);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDurationFramesChanged()
|
||||
{
|
||||
@@ -137,6 +185,8 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
/// <inheritdoc />
|
||||
public override void OnDestroy()
|
||||
{
|
||||
_instanceData = null;
|
||||
_instanceTypeName = null;
|
||||
Type = ScriptType.Null;
|
||||
Object.Destroy(ref Instance);
|
||||
if (_isRegisteredForScriptsReload)
|
||||
@@ -181,14 +231,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var m = (AnimationEventMedia)e.Media[i];
|
||||
m.StartFrame = (int)stream.ReadSingle();
|
||||
m.DurationFrames = (int)stream.ReadSingle();
|
||||
var typeName = stream.ReadStrAnsi(13);
|
||||
var type = TypeUtils.GetType(typeName);
|
||||
if (type == ScriptType.Null)
|
||||
throw new Exception($"Unknown type {typeName}.");
|
||||
m.Init(type);
|
||||
stream.ReadJson(m.Instance);
|
||||
m.Load(stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,10 +243,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
var m = (AnimationEventMedia)e.Media[i];
|
||||
stream.Write((float)m.StartFrame);
|
||||
stream.Write((float)m.DurationFrames);
|
||||
stream.WriteStrAnsi(m.Type.TypeName, 13);
|
||||
stream.WriteJson(m.Instance);
|
||||
m.Save(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -631,7 +631,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
}
|
||||
}
|
||||
if (spriteIndex == -1)
|
||||
throw new FlaxException();
|
||||
throw new Exception();
|
||||
atlas.Count++;
|
||||
_atlases[atlasIndex] = atlas;
|
||||
var sprite = new SpriteHandle(atlas.Texture, spriteIndex);
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace FlaxEditor.Modules
|
||||
|
||||
// Call backend
|
||||
if (PrefabManager.Internal_ApplyAll(FlaxEngine.Object.GetUnmanagedPtr(instance)))
|
||||
throw new FlaxException("Failed to apply the prefab. See log to learn more.");
|
||||
throw new Exception("Failed to apply the prefab. See log to learn more.");
|
||||
|
||||
PrefabApplied?.Invoke(prefab, instance);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using FlaxEditor.CustomEditors.Editors;
|
||||
using FlaxEditor.GUI;
|
||||
using FlaxEditor.Scripting;
|
||||
@@ -421,13 +422,23 @@ namespace FlaxEditor.Surface.Archetypes
|
||||
TryParseText = (string filterText, out object[] data) =>
|
||||
{
|
||||
data = null;
|
||||
if (!filterText.StartsWith("#"))
|
||||
return false;
|
||||
if (Color.TryParseHex(filterText, out var color))
|
||||
if (filterText.StartsWith("#") && Color.TryParseHex(filterText, out var color))
|
||||
{
|
||||
// Color constant from hex
|
||||
data = new object[] { color };
|
||||
return true;
|
||||
}
|
||||
if (filterText.Length > 2)
|
||||
{
|
||||
var fieldName = char.ToUpperInvariant(filterText[0]) + filterText.Substring(1).ToLowerInvariant();
|
||||
var field = typeof(Color).GetField(fieldName, BindingFlags.Public | BindingFlags.Static);
|
||||
if (field != null && fieldName != "Zero")
|
||||
{
|
||||
// Color constant in-built
|
||||
data = new object[] { field.GetValue(null) };
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using FlaxEditor.Tools.Terrain.Brushes;
|
||||
using FlaxEngine;
|
||||
|
||||
@@ -129,9 +130,7 @@ namespace FlaxEditor.Tools.Terrain.Paint
|
||||
// Get the patch data (cached internally by the c++ core in editor)
|
||||
var sourceData = TerrainTools.GetSplatMapData(terrain, ref patch.PatchCoord, splatmapIndex);
|
||||
if (sourceData == null)
|
||||
{
|
||||
throw new FlaxException("Cannot modify terrain. Loading splatmap failed. See log for more info.");
|
||||
}
|
||||
throw new Exception("Cannot modify terrain. Loading splatmap failed. See log for more info.");
|
||||
|
||||
// Record patch data before editing it
|
||||
if (!gizmo.CurrentEditUndoAction.HashPatch(ref patch.PatchCoord))
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using FlaxEditor.Tools.Terrain.Brushes;
|
||||
using FlaxEngine;
|
||||
|
||||
@@ -128,9 +129,7 @@ namespace FlaxEditor.Tools.Terrain.Sculpt
|
||||
float* sourceHeights = EditHoles ? null : TerrainTools.GetHeightmapData(terrain, ref patch.PatchCoord);
|
||||
byte* sourceHoles = EditHoles ? TerrainTools.GetHolesMaskData(terrain, ref patch.PatchCoord) : null;
|
||||
if (sourceHeights == null && sourceHoles == null)
|
||||
{
|
||||
throw new FlaxException("Cannot modify terrain. Loading heightmap failed. See log for more info.");
|
||||
}
|
||||
throw new Exception("Cannot modify terrain. Loading heightmap failed. See log for more info.");
|
||||
|
||||
// Record patch data before editing it
|
||||
if (!gizmo.CurrentEditUndoAction.HashPatch(ref patch.PatchCoord))
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
var offset = Int2.Zero;
|
||||
var size = new Int2((int)Mathf.Sqrt(_heightmapLength));
|
||||
if (TerrainTools.ModifyHeightMap(Terrain, ref patchCoord, (float*)data, ref offset, ref size))
|
||||
throw new FlaxException("Failed to modify the heightmap.");
|
||||
throw new Exception("Failed to modify the heightmap.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
var offset = Int2.Zero;
|
||||
var size = new Int2((int)Mathf.Sqrt(_heightmapLength));
|
||||
if (TerrainTools.ModifyHolesMask(Terrain, ref patchCoord, (byte*)data, ref offset, ref size))
|
||||
throw new FlaxException("Failed to modify the terrain holes.");
|
||||
throw new Exception("Failed to modify the terrain holes.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace FlaxEditor.Tools.Terrain.Undo
|
||||
var offset = Int2.Zero;
|
||||
var size = new Int2((int)Mathf.Sqrt(_heightmapLength));
|
||||
if (TerrainTools.ModifySplatMap(Terrain, ref patchCoord, (int)tag, (Color32*)data, ref offset, ref size))
|
||||
throw new FlaxException("Failed to modify the splatmap.");
|
||||
throw new Exception("Failed to modify the splatmap.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace FlaxEditor.Actions
|
||||
if (actor == null)
|
||||
throw new ArgumentNullException(nameof(actor));
|
||||
if (!actor.HasPrefabLink)
|
||||
throw new FlaxException("Cannot register missing prefab link.");
|
||||
throw new Exception("Cannot register missing prefab link.");
|
||||
return new BreakPrefabLinkAction(false, actor);
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ namespace FlaxEditor.Actions
|
||||
private void DoLink()
|
||||
{
|
||||
if (_prefabObjectIds == null)
|
||||
throw new FlaxException("Cannot link prefab. Missing objects Ids mapping.");
|
||||
throw new Exception("Cannot link prefab. Missing objects Ids mapping.");
|
||||
|
||||
var actor = Object.Find<Actor>(ref _actorId);
|
||||
if (actor == null)
|
||||
throw new FlaxException("Cannot link prefab. Missing actor.");
|
||||
throw new Exception("Cannot link prefab. Missing actor.");
|
||||
|
||||
// Restore cached links
|
||||
foreach (var e in _prefabObjectIds)
|
||||
@@ -149,9 +149,9 @@ namespace FlaxEditor.Actions
|
||||
{
|
||||
var actor = Object.Find<Actor>(ref _actorId);
|
||||
if (actor == null)
|
||||
throw new FlaxException("Cannot break prefab link. Missing actor.");
|
||||
throw new Exception("Cannot break prefab link. Missing actor.");
|
||||
if (!actor.HasPrefabLink)
|
||||
throw new FlaxException("Cannot break missing prefab link.");
|
||||
throw new Exception("Cannot break missing prefab link.");
|
||||
|
||||
if (_prefabObjectIds == null)
|
||||
_prefabObjectIds = new Dictionary<Guid, Guid>(1024);
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace FlaxEditor.Utilities
|
||||
if (Level.UnloadAllScenes())
|
||||
{
|
||||
Profiler.EndEvent();
|
||||
throw new FlaxException("Failed to unload scenes.");
|
||||
throw new Exception("Failed to unload scenes.");
|
||||
}
|
||||
FlaxEngine.Scripting.FlushRemovedObjects();
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace FlaxEditor.Utilities
|
||||
if (noScenes != null && noScenes.Length != 0)
|
||||
{
|
||||
Profiler.EndEvent();
|
||||
throw new FlaxException("Failed to unload scenes.");
|
||||
throw new Exception("Failed to unload scenes.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace FlaxEditor.Utilities
|
||||
if (scene == null)
|
||||
{
|
||||
Profiler.EndEvent();
|
||||
throw new FlaxException("Failed to deserialize scene");
|
||||
throw new Exception("Failed to deserialize scene");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace FlaxEditor.Utilities
|
||||
if (Level.UnloadAllScenes())
|
||||
{
|
||||
Profiler.EndEvent();
|
||||
throw new FlaxException("Failed to unload scenes.");
|
||||
throw new Exception("Failed to unload scenes.");
|
||||
}
|
||||
FlaxEngine.Scripting.FlushRemovedObjects();
|
||||
Profiler.EndEvent();
|
||||
@@ -154,7 +154,7 @@ namespace FlaxEditor.Utilities
|
||||
if (scene == null)
|
||||
{
|
||||
Profiler.EndEvent();
|
||||
throw new FlaxException("Failed to deserialize scene");
|
||||
throw new Exception("Failed to deserialize scene");
|
||||
}
|
||||
|
||||
// Restore `dirty` state
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using FlaxEngine;
|
||||
using Object = FlaxEngine.Object;
|
||||
|
||||
namespace FlaxEditor.Viewport.Previews
|
||||
{
|
||||
@@ -39,7 +41,7 @@ namespace FlaxEditor.Viewport.Previews
|
||||
|
||||
// Wait for base (don't want to async material parameters set due to async loading)
|
||||
if (baseMaterial == null || baseMaterial.WaitForLoaded())
|
||||
throw new FlaxException("Cannot load IES Profile preview material.");
|
||||
throw new Exception("Cannot load IES Profile preview material.");
|
||||
|
||||
// Create preview material (virtual)
|
||||
_previewMaterial = baseMaterial.CreateVirtualInstance();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using FlaxEngine;
|
||||
using Object = FlaxEngine.Object;
|
||||
|
||||
@@ -54,7 +55,7 @@ namespace FlaxEditor.Viewport.Previews
|
||||
if (instance == null)
|
||||
{
|
||||
_prefab = null;
|
||||
throw new FlaxException("Failed to spawn a prefab for the preview.");
|
||||
throw new Exception("Failed to spawn a prefab for the preview.");
|
||||
}
|
||||
|
||||
// Set instance
|
||||
|
||||
@@ -319,10 +319,10 @@ namespace FlaxEditor.Viewport.Previews
|
||||
// Create preview material (virtual)
|
||||
var baseMaterial = FlaxEngine.Content.LoadAsyncInternal<Material>("Editor/TexturePreviewMaterial");
|
||||
if (baseMaterial == null)
|
||||
throw new FlaxException("Cannot load texture preview material.");
|
||||
throw new Exception("Cannot load texture preview material.");
|
||||
_previewMaterial = baseMaterial.CreateVirtualInstance();
|
||||
if (_previewMaterial == null)
|
||||
throw new FlaxException("Failed to create virtual material instance for preview material.");
|
||||
throw new Exception("Failed to create virtual material instance for preview material.");
|
||||
|
||||
// Add widgets
|
||||
if (useWidgets)
|
||||
|
||||
@@ -482,7 +482,6 @@ namespace FlaxEditor.Windows
|
||||
continue;
|
||||
|
||||
var startIndex = _textBuffer.Length;
|
||||
|
||||
switch (_timestampsFormats)
|
||||
{
|
||||
case InterfaceOptions.TimestampsFormats.Utc:
|
||||
@@ -496,12 +495,12 @@ namespace FlaxEditor.Windows
|
||||
_textBuffer.AppendFormat("[ {0:00}:{1:00}:{2:00}.{3:000} ]: ", diff.Hours, diff.Minutes, diff.Seconds, diff.Milliseconds);
|
||||
break;
|
||||
}
|
||||
|
||||
if (_showLogType)
|
||||
{
|
||||
_textBuffer.AppendFormat("[{0}] ", entry.Level);
|
||||
}
|
||||
|
||||
var prefixLength = _textBuffer.Length - startIndex;
|
||||
if (entry.Message.IndexOf('\r') != -1)
|
||||
entry.Message = entry.Message.Replace("\r", "");
|
||||
_textBuffer.Append(entry.Message);
|
||||
@@ -548,27 +547,34 @@ namespace FlaxEditor.Windows
|
||||
if (textBlock.Range.Length > 0)
|
||||
{
|
||||
// Parse compilation error/warning
|
||||
var match = _compileRegex.Match(entryText, line.FirstCharIndex, textBlock.Range.Length);
|
||||
if (match.Success)
|
||||
var regexStart = line.FirstCharIndex;
|
||||
if (j == 0)
|
||||
regexStart += prefixLength;
|
||||
var regexLength = line.LastCharIndex - regexStart;
|
||||
if (regexLength > 0)
|
||||
{
|
||||
switch (match.Groups["level"].Value)
|
||||
var match = _compileRegex.Match(entryText, regexStart, regexLength);
|
||||
if (match.Success)
|
||||
{
|
||||
case "error":
|
||||
textBlock.Style = _output.ErrorStyle;
|
||||
break;
|
||||
case "warning":
|
||||
textBlock.Style = _output.WarningStyle;
|
||||
break;
|
||||
switch (match.Groups["level"].Value)
|
||||
{
|
||||
case "error":
|
||||
textBlock.Style = _output.ErrorStyle;
|
||||
break;
|
||||
case "warning":
|
||||
textBlock.Style = _output.WarningStyle;
|
||||
break;
|
||||
}
|
||||
textBlock.Tag = new TextBlockTag
|
||||
{
|
||||
Type = TextBlockTag.Types.CodeLocation,
|
||||
Url = match.Groups["path"].Value,
|
||||
Line = int.Parse(match.Groups["line"].Value),
|
||||
};
|
||||
}
|
||||
textBlock.Tag = new TextBlockTag
|
||||
{
|
||||
Type = TextBlockTag.Types.CodeLocation,
|
||||
Url = match.Groups["path"].Value,
|
||||
Line = int.Parse(match.Groups["line"].Value),
|
||||
};
|
||||
// TODO: parsing hyperlinks with link
|
||||
// TODO: parsing file paths with link
|
||||
}
|
||||
// TODO: parsing hyperlinks with link
|
||||
// TODO: parsing file paths with link
|
||||
}
|
||||
|
||||
prevBlockBottom += line.Size.Y;
|
||||
|
||||
@@ -326,7 +326,7 @@ namespace FlaxEditor.Windows
|
||||
|
||||
_isUpdatingSelection = false;
|
||||
}
|
||||
|
||||
|
||||
private bool ValidateDragAsset(AssetItem assetItem)
|
||||
{
|
||||
return assetItem.OnEditorDrag(this);
|
||||
@@ -417,7 +417,7 @@ namespace FlaxEditor.Windows
|
||||
public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data)
|
||||
{
|
||||
var result = base.OnDragEnter(ref location, data);
|
||||
if (result == DragDropEffect.None && Editor.StateMachine.CurrentState.CanEditScene)
|
||||
if (Editor.StateMachine.CurrentState.CanEditScene)
|
||||
{
|
||||
if (_dragHandlers == null)
|
||||
_dragHandlers = new DragHandlers();
|
||||
@@ -426,14 +426,14 @@ namespace FlaxEditor.Windows
|
||||
_dragAssets = new DragAssets(ValidateDragAsset);
|
||||
_dragHandlers.Add(_dragAssets);
|
||||
}
|
||||
if (_dragAssets.OnDragEnter(data))
|
||||
if (_dragAssets.OnDragEnter(data) && result == DragDropEffect.None)
|
||||
return _dragAssets.Effect;
|
||||
if (_dragActorType == null)
|
||||
{
|
||||
_dragActorType = new DragActorType(ValidateDragActorType);
|
||||
_dragHandlers.Add(_dragActorType);
|
||||
}
|
||||
if (_dragActorType.OnDragEnter(data))
|
||||
if (_dragActorType.OnDragEnter(data) && result == DragDropEffect.None)
|
||||
return _dragActorType.Effect;
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user