Merge remote-tracking branch 'origin/master' into gi
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2022 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.CustomEditors;
|
||||
using FlaxEditor.GUI;
|
||||
@@ -106,13 +107,36 @@ namespace FlaxEditor.Windows.Assets
|
||||
/// <inheritdoc />
|
||||
protected override void OnAssetLoaded()
|
||||
{
|
||||
_object = Asset.CreateInstance();
|
||||
_object = Asset.Instance;
|
||||
if (_object == null)
|
||||
{
|
||||
// Hint developer about cause of failure
|
||||
var dataTypeName = Asset.DataTypeName;
|
||||
var type = Type.GetType(dataTypeName);
|
||||
if (type != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var obj = Activator.CreateInstance(type);
|
||||
var data = Asset.Data;
|
||||
FlaxEngine.Json.JsonSerializer.Deserialize(obj, data);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_presenter.NoSelectionText = "Failed to load asset. See log for more. " + ex.Message.Replace('\n', ' ');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_presenter.NoSelectionText = string.Format("Missing type '{0}'.", dataTypeName);
|
||||
}
|
||||
}
|
||||
_presenter.Select(_object);
|
||||
_undo.Clear();
|
||||
ClearEditedFlag();
|
||||
|
||||
// Auto-close on scripting reload if json asset is from game scripts (it might be reloaded)
|
||||
if (_object != null && FlaxEngine.Scripting.IsTypeFromGameScripts(_object.GetType()) && !_isRegisteredForScriptsReload)
|
||||
if ((_object == null || FlaxEngine.Scripting.IsTypeFromGameScripts(_object.GetType())) && !_isRegisteredForScriptsReload)
|
||||
{
|
||||
_isRegisteredForScriptsReload = true;
|
||||
ScriptsBuilder.ScriptsReloadBegin += OnScriptsReloadBegin;
|
||||
@@ -121,6 +145,14 @@ namespace FlaxEditor.Windows.Assets
|
||||
base.OnAssetLoaded();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnAssetLoadFailed()
|
||||
{
|
||||
_presenter.NoSelectionText = "Failed to load the asset.";
|
||||
|
||||
base.OnAssetLoadFailed();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnItemReimported(ContentItem item)
|
||||
{
|
||||
|
||||
@@ -77,6 +77,10 @@ namespace FlaxEditor.Windows.Assets
|
||||
[EditorOrder(200), DefaultValue(true), EditorDisplay("Transparency"), Tooltip("Enables reflections when rendering material.")]
|
||||
public bool EnableReflections;
|
||||
|
||||
[VisibleIf(nameof(EnableReflections))]
|
||||
[EditorOrder(210), DefaultValue(false), EditorDisplay("Transparency"), Tooltip("Enables Screen Space Reflections when rendering material.")]
|
||||
public bool EnableScreenSpaceReflections;
|
||||
|
||||
[EditorOrder(210), DefaultValue(true), EditorDisplay("Transparency"), Tooltip("Enables fog effects when rendering material.")]
|
||||
public bool EnableFog;
|
||||
|
||||
@@ -142,6 +146,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
DepthTest = (info.FeaturesFlags & MaterialFeaturesFlags.DisableDepthTest) == 0;
|
||||
DepthWrite = (info.FeaturesFlags & MaterialFeaturesFlags.DisableDepthWrite) == 0;
|
||||
EnableReflections = (info.FeaturesFlags & MaterialFeaturesFlags.DisableReflections) == 0;
|
||||
EnableScreenSpaceReflections = (info.FeaturesFlags & MaterialFeaturesFlags.ScreenSpaceReflections) != 0;
|
||||
EnableFog = (info.FeaturesFlags & MaterialFeaturesFlags.DisableFog) == 0;
|
||||
EnableDistortion = (info.FeaturesFlags & MaterialFeaturesFlags.DisableDistortion) == 0;
|
||||
PixelNormalOffsetRefraction = (info.FeaturesFlags & MaterialFeaturesFlags.PixelNormalOffsetRefraction) != 0;
|
||||
@@ -177,6 +182,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
info.FeaturesFlags |= MaterialFeaturesFlags.DisableDepthWrite;
|
||||
if (!EnableReflections)
|
||||
info.FeaturesFlags |= MaterialFeaturesFlags.DisableReflections;
|
||||
if (EnableScreenSpaceReflections)
|
||||
info.FeaturesFlags |= MaterialFeaturesFlags.ScreenSpaceReflections;
|
||||
if (!EnableFog)
|
||||
info.FeaturesFlags |= MaterialFeaturesFlags.DisableFog;
|
||||
if (!EnableDistortion)
|
||||
|
||||
Reference in New Issue
Block a user