Merge remote-tracking branch 'origin/master' into 1.11
# Conflicts: # Content/Editor/DebugMaterials/DDGIDebugProbes.flax # Source/Editor/Windows/OutputLogWindow.cs # Source/Engine/Level/Actor.cpp
This commit is contained in:
42
.github/ISSUE_TEMPLATE/1-bug.yaml
vendored
Normal file
42
.github/ISSUE_TEMPLATE/1-bug.yaml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: Bug Report
|
||||
description: File a bug report.
|
||||
title: "[Bug]: "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report! Please attach any minimal repoduction projects!
|
||||
- type: textarea
|
||||
id: description-area
|
||||
attributes:
|
||||
label: Description
|
||||
description: Please provide a description and what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps-area
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: Please provide an repoduction steps.
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: version
|
||||
attributes:
|
||||
label: Version
|
||||
description: What version of Flax are you running?
|
||||
options:
|
||||
- 1.8
|
||||
- 1.9
|
||||
- 1.10
|
||||
- 1.11
|
||||
- master branch
|
||||
default: 2
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant logs
|
||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||
render: shell
|
||||
22
.github/ISSUE_TEMPLATE/2-feature-request.yaml
vendored
Normal file
22
.github/ISSUE_TEMPLATE/2-feature-request.yaml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Feature Request
|
||||
description: File a feature request.
|
||||
title: "[Request]: "
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out a feature request!
|
||||
- type: textarea
|
||||
id: description-area
|
||||
attributes:
|
||||
label: Description
|
||||
description: Please provide a description of the feature!
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: benifits-area
|
||||
attributes:
|
||||
label: Benifits
|
||||
description: Please provide what benifits this feature would provide to the engine!
|
||||
validations:
|
||||
required: true
|
||||
BIN
Content/Editor/Camera/M_Camera.flax
(Stored with Git LFS)
BIN
Content/Editor/Camera/M_Camera.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/CubeTexturePreviewMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/CubeTexturePreviewMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/DebugMaterials/SingleColor/Decal.flax
(Stored with Git LFS)
BIN
Content/Editor/DebugMaterials/SingleColor/Decal.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/DebugMaterials/SingleColor/Particle.flax
(Stored with Git LFS)
BIN
Content/Editor/DebugMaterials/SingleColor/Particle.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/DebugMaterials/SingleColor/Surface.flax
(Stored with Git LFS)
BIN
Content/Editor/DebugMaterials/SingleColor/Surface.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax
(Stored with Git LFS)
BIN
Content/Editor/DebugMaterials/SingleColor/SurfaceAdditive.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/DebugMaterials/SingleColor/Terrain.flax
(Stored with Git LFS)
BIN
Content/Editor/DebugMaterials/SingleColor/Terrain.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/DefaultFontMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/DefaultFontMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Gizmo/FoliageBrushMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/Gizmo/FoliageBrushMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Gizmo/Material.flax
(Stored with Git LFS)
BIN
Content/Editor/Gizmo/Material.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Gizmo/MaterialAxisLocked.flax
(Stored with Git LFS)
BIN
Content/Editor/Gizmo/MaterialAxisLocked.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Gizmo/MaterialWire.flax
(Stored with Git LFS)
BIN
Content/Editor/Gizmo/MaterialWire.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Gizmo/SelectionOutlineMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/Gizmo/SelectionOutlineMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/Gizmo/VertexColorsPreviewMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Highlight Material.flax
(Stored with Git LFS)
BIN
Content/Editor/Highlight Material.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Icons/IconsMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/Icons/IconsMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/IesProfilePreviewMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/IesProfilePreviewMaterial.flax
(Stored with Git LFS)
Binary file not shown.
@@ -27,6 +27,7 @@ TextureCube EnvProbe : register(t__SRV__);
|
||||
TextureCube SkyLightTexture : register(t__SRV__);
|
||||
Buffer<float4> ShadowsBuffer : register(t__SRV__);
|
||||
Texture2D<float> ShadowMap : register(t__SRV__);
|
||||
Texture3D VolumetricFogTexture : register(t__SRV__);
|
||||
@4// Forward Shading: Utilities
|
||||
// Public accessors for lighting data, use them as data binding might change but those methods will remain.
|
||||
LightData GetDirectionalLight() { return DirectionalLight; }
|
||||
@@ -153,6 +154,18 @@ void PS_Forward(
|
||||
// Calculate exponential height fog
|
||||
float4 fog = GetExponentialHeightFog(ExponentialHeightFog, materialInput.WorldPosition, ViewPos, 0, gBuffer.ViewPos.z);
|
||||
|
||||
if (ExponentialHeightFog.VolumetricFogMaxDistance > 0)
|
||||
{
|
||||
// Sample volumetric fog and mix it in
|
||||
float2 screenUV = materialInput.SvPosition.xy * ScreenSize.zw;
|
||||
float3 viewVector = materialInput.WorldPosition - ViewPos;
|
||||
float sceneDepth = length(viewVector);
|
||||
float depthSlice = sceneDepth / ExponentialHeightFog.VolumetricFogMaxDistance;
|
||||
float3 volumeUV = float3(screenUV, depthSlice);
|
||||
float4 volumetricFog = VolumetricFogTexture.SampleLevel(SamplerLinearClamp, volumeUV, 0);
|
||||
fog = CombineVolumetricFog(fog, volumetricFog);
|
||||
}
|
||||
|
||||
// Apply fog to the output color
|
||||
#if MATERIAL_BLEND == MATERIAL_BLEND_OPAQUE
|
||||
output = float4(output.rgb * fog.a + fog.rgb, output.a);
|
||||
|
||||
@@ -645,7 +645,7 @@ VertexOutput VS_Ribbon(RibbonInput input, uint vertexIndex : SV_VertexID)
|
||||
materialInput.TBN = output.TBN;
|
||||
materialInput.TwoSidedSign = 1;
|
||||
materialInput.SvPosition = output.Position;
|
||||
materialInput.PreSkinnedPosition = Position;
|
||||
materialInput.PreSkinnedPosition = position;
|
||||
materialInput.PreSkinnedNormal = tangentToLocal[2].xyz;
|
||||
materialInput.InstanceOrigin = output.InstanceOrigin;
|
||||
materialInput.InstanceParams = output.InstanceParams;
|
||||
|
||||
BIN
Content/Editor/Particles/Particle Material Color.flax
(Stored with Git LFS)
BIN
Content/Editor/Particles/Particle Material Color.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Particles/Smoke Material.flax
(Stored with Git LFS)
BIN
Content/Editor/Particles/Smoke Material.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/SpriteMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/SpriteMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Terrain/Circle Brush Material.flax
(Stored with Git LFS)
BIN
Content/Editor/Terrain/Circle Brush Material.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Terrain/Highlight Terrain Material.flax
(Stored with Git LFS)
BIN
Content/Editor/Terrain/Highlight Terrain Material.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/TexturePreviewMaterial.flax
(Stored with Git LFS)
BIN
Content/Editor/TexturePreviewMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Editor/Wires Debug Material.flax
(Stored with Git LFS)
BIN
Content/Editor/Wires Debug Material.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Engine/DefaultDeformableMaterial.flax
(Stored with Git LFS)
BIN
Content/Engine/DefaultDeformableMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Engine/DefaultMaterial.flax
(Stored with Git LFS)
BIN
Content/Engine/DefaultMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Engine/DefaultRadialMenu.flax
(Stored with Git LFS)
BIN
Content/Engine/DefaultRadialMenu.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Engine/DefaultTerrainMaterial.flax
(Stored with Git LFS)
BIN
Content/Engine/DefaultTerrainMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Engine/SingleColorMaterial.flax
(Stored with Git LFS)
BIN
Content/Engine/SingleColorMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Engine/SkyboxMaterial.flax
(Stored with Git LFS)
BIN
Content/Engine/SkyboxMaterial.flax
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Shaders/Fog.flax
(Stored with Git LFS)
BIN
Content/Shaders/Fog.flax
(Stored with Git LFS)
Binary file not shown.
@@ -1,19 +0,0 @@
|
||||
<!-- Please search existing issues for potential duplicates before filing yours:
|
||||
https://github.com/flaxengine/FlaxEngine/issues?q=is%3Aissue
|
||||
-->
|
||||
|
||||
**Issue description:**
|
||||
<!-- What happened, and what was expected. -->
|
||||
<!-- Log file, can be found in the project directory's `Logs` folder (optional) -->
|
||||
|
||||
**Steps to reproduce:**
|
||||
<!-- Enter minimal reproduction steps if available. -->
|
||||
|
||||
|
||||
**Minimal reproduction project:**
|
||||
<!-- Recommended as it greatly speeds up debugging. Drag and drop a zip archive to upload it. -->
|
||||
|
||||
|
||||
**Flax version:**
|
||||
<!-- Specify version number. -->
|
||||
|
||||
@@ -117,7 +117,8 @@ namespace FlaxEditor.Content.Create
|
||||
|
||||
private static bool IsValid(Type type)
|
||||
{
|
||||
return (type.IsPublic || type.IsNestedPublic) && !type.IsAbstract && !type.IsGenericType;
|
||||
var controlTypes = Editor.Instance.CodeEditing.Controls.Get();
|
||||
return (type.IsPublic || type.IsNestedPublic) && !type.IsAbstract && !type.IsGenericType && controlTypes.Contains(new ScriptType(type));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,8 +87,11 @@ namespace FlaxEditor.CustomEditors
|
||||
var targetTypeType = TypeUtils.GetType(targetType);
|
||||
if (canUseRefPicker)
|
||||
{
|
||||
// TODO: add generic way of CustomEditor for ref pickers (use it on AssetRefEditor/GPUTextureEditor/...)
|
||||
if (typeof(Asset).IsAssignableFrom(targetTypeType))
|
||||
return new AssetRefEditor();
|
||||
if (typeof(GPUTexture).IsAssignableFrom(targetTypeType))
|
||||
return new GPUTextureEditor();
|
||||
if (typeof(FlaxEngine.Object).IsAssignableFrom(targetTypeType))
|
||||
return new FlaxObjectRefEditor();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
public class AudioSourceEditor : ActorEditor
|
||||
{
|
||||
private Label _infoLabel;
|
||||
private Slider _slider;
|
||||
private AudioSource.States _slideStartState;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
@@ -28,6 +30,13 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
_infoLabel = playbackGroup.Label(string.Empty).Label;
|
||||
_infoLabel.AutoHeight = true;
|
||||
|
||||
// Play back slider
|
||||
var sliderElement = playbackGroup.CustomContainer<Slider>();
|
||||
_slider = sliderElement.CustomControl;
|
||||
_slider.ThumbSize = new Float2(_slider.ThumbSize.X * 0.5f, _slider.ThumbSize.Y);
|
||||
_slider.SlidingStart += OnSlidingStart;
|
||||
_slider.SlidingEnd += OnSlidingEnd;
|
||||
|
||||
var grid = playbackGroup.UniformGrid();
|
||||
var gridControl = grid.CustomControl;
|
||||
gridControl.ClipChildren = false;
|
||||
@@ -40,6 +49,38 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSlidingEnd()
|
||||
{
|
||||
foreach (var value in Values)
|
||||
{
|
||||
if (value is AudioSource audioSource && audioSource.Clip)
|
||||
{
|
||||
switch (_slideStartState)
|
||||
{
|
||||
case AudioSource.States.Playing:
|
||||
audioSource.Play();
|
||||
break;
|
||||
case AudioSource.States.Paused:
|
||||
case AudioSource.States.Stopped:
|
||||
audioSource.Pause();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSlidingStart()
|
||||
{
|
||||
foreach (var value in Values)
|
||||
{
|
||||
if (value is AudioSource audioSource && audioSource.Clip)
|
||||
{
|
||||
_slideStartState = audioSource.State;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Refresh()
|
||||
{
|
||||
@@ -51,7 +92,29 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
foreach (var value in Values)
|
||||
{
|
||||
if (value is AudioSource audioSource && audioSource.Clip)
|
||||
{
|
||||
text += $"Time: {audioSource.Time:##0.0}s / {audioSource.Clip.Length:##0.0}s\n";
|
||||
_slider.Maximum = audioSource.Clip.Length;
|
||||
_slider.Minimum = 0;
|
||||
if (_slider.IsSliding)
|
||||
{
|
||||
if (audioSource.State != AudioSource.States.Playing)
|
||||
{
|
||||
// Play to move slider correctly
|
||||
audioSource.Play();
|
||||
audioSource.Time = _slider.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioSource.Time = _slider.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_slider.Value = audioSource.Time;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
_infoLabel.Text = text;
|
||||
}
|
||||
|
||||
68
Source/Editor/CustomEditors/Dedicated/GPUTextureEditor.cs
Normal file
68
Source/Editor/CustomEditors/Dedicated/GPUTextureEditor.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Dedicated
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic editor/viewer for <see cref="GPUTexture"/>.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(GPUTexture)), DefaultEditor]
|
||||
public class GPUTextureEditor : CustomEditor
|
||||
{
|
||||
private Image _image;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DisplayStyle Style => DisplayStyle.Inline;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
_image = new Image
|
||||
{
|
||||
Brush = new GPUTextureBrush(),
|
||||
Size = new Float2(200, 100),
|
||||
Parent = layout.ContainerControl,
|
||||
};
|
||||
_image.Clicked += OnImageClicked;
|
||||
}
|
||||
|
||||
private void OnImageClicked(Image image, MouseButton button)
|
||||
{
|
||||
var texture = Values[0] as GPUTexture;
|
||||
if (!texture)
|
||||
return;
|
||||
var menu = new ContextMenu();
|
||||
menu.AddButton("Save...", () => Screenshot.Capture(Values[0] as GPUTexture));
|
||||
menu.AddButton("Enlarge", () => _image.Size *= 2);
|
||||
menu.AddButton("Shrink", () => _image.Size /= 2).Enabled = _image.Height > 32;
|
||||
var location = image.PointFromScreen(Input.MouseScreenPosition);
|
||||
menu.Show(image, location);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
|
||||
var texture = Values[0] as GPUTexture;
|
||||
((GPUTextureBrush)_image.Brush).Texture = texture;
|
||||
if (texture)
|
||||
{
|
||||
var desc = texture.Description;
|
||||
#if BUILD_RELEASE
|
||||
var name = string.Empty;
|
||||
#else
|
||||
var name = texture.Name;
|
||||
#endif
|
||||
_image.TooltipText = $"{name}\nType: {texture.ResourceType}\nSize: {desc.Width}x{desc.Height}\nFormat: {desc.Format}\nMemory: {Utilities.Utils.FormatBytesCount(texture.MemoryUsage)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
_image.TooltipText = "None";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
{
|
||||
ScriptName = scriptName;
|
||||
TooltipText = "Create a new script";
|
||||
DrawHighlights = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
var buttonHeight = (textSize.Y < 18) ? 18 : textSize.Y + 4;
|
||||
_addScriptsButton = new Button
|
||||
{
|
||||
TooltipText = "Add new scripts to the actor",
|
||||
TooltipText = "Add new scripts to the actor.",
|
||||
AnchorPreset = AnchorPresets.MiddleCenter,
|
||||
Text = buttonText,
|
||||
Parent = this,
|
||||
@@ -114,7 +115,16 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
cm.TextChanged += text =>
|
||||
{
|
||||
if (!IsValidScriptName(text))
|
||||
{
|
||||
// Remove NewScriptItems
|
||||
List<Control> newScriptItems = cm.ItemsPanel.Children.FindAll(c => c is NewScriptItem);
|
||||
foreach (var item in newScriptItems)
|
||||
{
|
||||
cm.ItemsPanel.RemoveChild(item);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (!cm.ItemsPanel.Children.Any(x => x.Visible && x is not NewScriptItem))
|
||||
{
|
||||
// If there are no visible items, that means the search failed so we can find the create script button or create one if it's the first time
|
||||
@@ -876,7 +886,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
|
||||
// Add drag button to the group
|
||||
var scriptDrag = new DragImage
|
||||
{
|
||||
TooltipText = "Script reference",
|
||||
TooltipText = "Script reference.",
|
||||
AutoFocus = true,
|
||||
IsScrollable = false,
|
||||
Color = FlaxEngine.GUI.Style.Current.ForegroundGrey,
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
menu.AddButton("Copy", linkedEditor.Copy);
|
||||
var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
|
||||
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly && Editor._canResize;
|
||||
b = menu.AddButton("Paste", linkedEditor.Paste);
|
||||
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||
|
||||
@@ -407,7 +407,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
menu.AddButton("Copy", linkedEditor.Copy);
|
||||
var b = menu.AddButton("Duplicate", () => Editor.Duplicate(Index));
|
||||
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||
b.Enabled = linkedEditor.CanPaste && !Editor._readOnly && Editor._canResize;
|
||||
var paste = menu.AddButton("Paste", linkedEditor.Paste);
|
||||
paste.Enabled = linkedEditor.CanPaste && !Editor._readOnly;
|
||||
|
||||
@@ -422,7 +422,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
moveDownButton.Enabled = Index + 1 < Editor.Count;
|
||||
}
|
||||
|
||||
menu.AddButton("Remove", OnRemoveClicked);
|
||||
b = menu.AddButton("Remove", OnRemoveClicked);
|
||||
b.Enabled = !Editor._readOnly && Editor._canResize;
|
||||
|
||||
menu.Show(panel, location);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
using System;
|
||||
using FlaxEditor.GUI;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.Utilities;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Editors
|
||||
@@ -81,9 +82,13 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
private OptionType[] _options;
|
||||
private ScriptType _type;
|
||||
private Elements.PropertiesListElement _typeItem;
|
||||
|
||||
private ScriptType Type => Values[0] == null ? Values.Type : TypeUtils.GetObjectType(Values[0]);
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool RevertValueWithChildren => false; // Always revert value for a whole object
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
@@ -98,7 +103,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
_type = type;
|
||||
|
||||
// Type
|
||||
var typeEditor = layout.ComboBox(TypeComboBoxName, "Type of the object value. Use it to change the object.");
|
||||
_typeItem = layout.AddPropertyItem(TypeComboBoxName, "Type of the object value. Use it to change the object.");
|
||||
var typeEditor = _typeItem.ComboBox();
|
||||
for (int i = 0; i < _options.Length; i++)
|
||||
{
|
||||
typeEditor.ComboBox.AddItem(_options[i].Name);
|
||||
@@ -126,6 +132,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
|
||||
// Value
|
||||
var values = new CustomValueContainer(type, (instance, index) => instance);
|
||||
if (Values.HasReferenceValue)
|
||||
values.SetReferenceValue(Values.ReferenceValue);
|
||||
values.AddRange(Values);
|
||||
var editor = CustomEditorsUtil.CreateEditor(type);
|
||||
var style = editor.Style;
|
||||
@@ -170,6 +178,12 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
{
|
||||
base.Refresh();
|
||||
|
||||
// Show prefab diff when reference value type is different
|
||||
var color = Color.Transparent;
|
||||
if (Values.HasReferenceValue && CanRevertReferenceValue && Values[0]?.GetType() != Values.ReferenceValue?.GetType())
|
||||
color = FlaxEngine.GUI.Style.Current.BackgroundSelected;
|
||||
_typeItem.Labels[0].HighlightStripColor = color;
|
||||
|
||||
// Check if type has been modified outside the editor (eg. from code)
|
||||
if (Type != _type)
|
||||
{
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace FlaxEditor
|
||||
private readonly List<EditorModule> _modules = new List<EditorModule>(16);
|
||||
private bool _isAfterInit, _areModulesInited, _areModulesAfterInitEnd, _isHeadlessMode, _autoExit;
|
||||
private string _projectToOpen;
|
||||
private bool _projectIsNew;
|
||||
private float _lastAutoSaveTimer, _autoExitTimeout = 0.1f;
|
||||
private Button _saveNowButton;
|
||||
private Button _cancelSaveButton;
|
||||
@@ -737,11 +738,12 @@ namespace FlaxEditor
|
||||
var procSettings = new CreateProcessSettings
|
||||
{
|
||||
FileName = Platform.ExecutableFilePath,
|
||||
Arguments = string.Format("-project \"{0}\"", _projectToOpen),
|
||||
Arguments = string.Format("-project \"{0}\"" + (_projectIsNew ? " -new" : string.Empty), _projectToOpen),
|
||||
ShellExecute = true,
|
||||
WaitForEnd = false,
|
||||
HiddenWindow = false,
|
||||
};
|
||||
_projectIsNew = false;
|
||||
_projectToOpen = null;
|
||||
Platform.CreateProcess(ref procSettings);
|
||||
}
|
||||
@@ -790,6 +792,24 @@ namespace FlaxEditor
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the given project. Afterwards closes this project with running editor and opens the given project.
|
||||
/// </summary>
|
||||
/// <param name="projectFilePath">The project file path.</param>
|
||||
public void NewProject(string projectFilePath)
|
||||
{
|
||||
if (projectFilePath == null)
|
||||
{
|
||||
MessageBox.Show("Missing project");
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache project path and start editor exit (it will open new instance on valid closing)
|
||||
_projectToOpen = StringUtils.NormalizePath(Path.GetDirectoryName(projectFilePath));
|
||||
_projectIsNew = true;
|
||||
Windows.MainWindow.Close(ClosingReason.User);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes this project with running editor and opens the given project.
|
||||
/// </summary>
|
||||
|
||||
@@ -51,6 +51,11 @@ namespace FlaxEditor.GUI
|
||||
/// </summary>
|
||||
public float SortScore;
|
||||
|
||||
/// <summary>
|
||||
/// Wether the query highlights should be draw.
|
||||
/// </summary>
|
||||
public bool DrawHighlights = true;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when items gets clicked by the user.
|
||||
/// </summary>
|
||||
@@ -165,7 +170,7 @@ namespace FlaxEditor.GUI
|
||||
Render2D.FillRectangle(new Rectangle(Float2.Zero, Size), style.BackgroundHighlighted);
|
||||
|
||||
// Draw all highlights
|
||||
if (_highlights != null)
|
||||
if (DrawHighlights && _highlights != null)
|
||||
{
|
||||
var color = style.ProgressNormal * 0.6f;
|
||||
for (int i = 0; i < _highlights.Count; i++)
|
||||
|
||||
@@ -10,6 +10,7 @@ using System.Text;
|
||||
using FlaxEditor.GUI.Timeline.Undo;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using FlaxEngine.Json;
|
||||
using FlaxEngine.Utilities;
|
||||
|
||||
namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
@@ -54,7 +55,10 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
var paramTypeName = LoadName(stream);
|
||||
e.EventParamsTypes[i] = TypeUtils.GetManagedType(paramTypeName);
|
||||
if (e.EventParamsTypes[i] == null)
|
||||
{
|
||||
Editor.LogError($"Unknown type {paramTypeName}.");
|
||||
isInvalid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isInvalid)
|
||||
@@ -82,7 +86,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
for (int j = 0; j < paramsCount; j++)
|
||||
{
|
||||
stream.Read(dataBuffer, 0, e.EventParamsSizes[j]);
|
||||
key.Parameters[j] = Marshal.PtrToStructure(handle.AddrOfPinnedObject(), e.EventParamsTypes[j]);
|
||||
key.Parameters[j] = Utilities.Utils.ByteArrayToStructure(handle.AddrOfPinnedObject(), e.EventParamsTypes[j], e.EventParamsSizes[j]);
|
||||
}
|
||||
|
||||
events[i] = new KeyframesEditor.Keyframe
|
||||
@@ -125,8 +129,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
|
||||
for (int j = 0; j < paramsCount; j++)
|
||||
{
|
||||
Marshal.StructureToPtr(key.Parameters[j], ptr, true);
|
||||
Marshal.Copy(ptr, dataBuffer, 0, e.EventParamsSizes[j]);
|
||||
Utilities.Utils.StructureToByteArray(key.Parameters[j], e.EventParamsSizes[j], ptr, dataBuffer);
|
||||
stream.Write(dataBuffer, 0, e.EventParamsSizes[j]);
|
||||
}
|
||||
}
|
||||
@@ -153,7 +156,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
/// <summary>
|
||||
/// The event key data.
|
||||
/// </summary>
|
||||
public struct EventKey
|
||||
public struct EventKey : ICloneable
|
||||
{
|
||||
/// <summary>
|
||||
/// The parameters values.
|
||||
@@ -178,6 +181,26 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
sb.Append(')');
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object Clone()
|
||||
{
|
||||
if (Parameters == null)
|
||||
return new EventKey();
|
||||
|
||||
// Deep clone parameter values (especially boxed value types need to be duplicated to avoid referencing the same ones)
|
||||
var parameters = new object[Parameters.Length];
|
||||
for (int i = 0; i < parameters.Length; i++)
|
||||
{
|
||||
var p = Parameters[i];
|
||||
if (p == null || p is FlaxEngine.Object)
|
||||
parameters[i] = Parameters[i];
|
||||
else
|
||||
parameters[i] = JsonSerializer.Deserialize(JsonSerializer.Serialize(p), p.GetType());
|
||||
}
|
||||
|
||||
return new EventKey { Parameters = parameters };
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -234,6 +257,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
var time = Timeline.CurrentTime;
|
||||
if (!TryGetValue(out var value))
|
||||
value = Events.Evaluate(time);
|
||||
value = ((ICloneable)value).Clone();
|
||||
|
||||
// Find event at the current location
|
||||
for (int i = Events.Keyframes.Count - 1; i >= 0; i--)
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
{
|
||||
var time = stream.ReadSingle();
|
||||
stream.Read(dataBuffer, 0, e.ValueSize);
|
||||
var value = Marshal.PtrToStructure(handle.AddrOfPinnedObject(), propertyType);
|
||||
var value = Utilities.Utils.ByteArrayToStructure(handle.AddrOfPinnedObject(), propertyType, e.ValueSize);
|
||||
|
||||
keyframes[i] = new KeyframesEditor.Keyframe
|
||||
{
|
||||
@@ -142,8 +142,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
|
||||
for (int i = 0; i < keyframes.Count; i++)
|
||||
{
|
||||
var keyframe = keyframes[i];
|
||||
Marshal.StructureToPtr(keyframe.Value, ptr, true);
|
||||
Marshal.Copy(ptr, dataBuffer, 0, e.ValueSize);
|
||||
Utilities.Utils.StructureToByteArray(keyframe.Value, e.ValueSize, ptr, dataBuffer);
|
||||
stream.Write(keyframe.Time);
|
||||
stream.Write(dataBuffer);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
// Copyright (c) Wojciech Figat. All rights reserved.
|
||||
|
||||
using FlaxEditor.Options;
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEngine;
|
||||
using System;
|
||||
|
||||
namespace FlaxEditor.Gizmo
|
||||
{
|
||||
@@ -21,12 +19,16 @@ namespace FlaxEditor.Gizmo
|
||||
private MaterialInstance _materialAxisY;
|
||||
private MaterialInstance _materialAxisZ;
|
||||
private MaterialInstance _materialAxisFocus;
|
||||
private MaterialInstance _materialAxisLocked;
|
||||
private MaterialBase _materialSphere;
|
||||
|
||||
// Material Parameter Names
|
||||
const String _brightnessParamName = "Brightness";
|
||||
const String _opacityParamName = "Opacity";
|
||||
private const string _brightnessParamName = "Brightness";
|
||||
private const string _opacityParamName = "Opacity";
|
||||
|
||||
/// <summary>
|
||||
/// Used for example when the selection can't be moved because one actor is static.
|
||||
/// </summary>
|
||||
private bool _isDisabled;
|
||||
|
||||
private void InitDrawing()
|
||||
{
|
||||
@@ -42,7 +44,6 @@ namespace FlaxEditor.Gizmo
|
||||
_materialAxisY = FlaxEngine.Content.LoadAsyncInternal<MaterialInstance>("Editor/Gizmo/MaterialAxisY");
|
||||
_materialAxisZ = FlaxEngine.Content.LoadAsyncInternal<MaterialInstance>("Editor/Gizmo/MaterialAxisZ");
|
||||
_materialAxisFocus = FlaxEngine.Content.LoadAsyncInternal<MaterialInstance>("Editor/Gizmo/MaterialAxisFocus");
|
||||
_materialAxisLocked = FlaxEngine.Content.LoadAsyncInternal<MaterialInstance>("Editor/Gizmo/MaterialAxisLocked");
|
||||
_materialSphere = FlaxEngine.Content.LoadAsyncInternal<MaterialInstance>("Editor/Gizmo/MaterialSphere");
|
||||
|
||||
// Ensure that every asset was loaded
|
||||
@@ -67,17 +68,42 @@ namespace FlaxEditor.Gizmo
|
||||
|
||||
private void OnEditorOptionsChanged(EditorOptions options)
|
||||
{
|
||||
float brightness = options.Visual.TransformGizmoBrightness;
|
||||
_materialAxisX.SetParameterValue(_brightnessParamName, brightness);
|
||||
_materialAxisY.SetParameterValue(_brightnessParamName, brightness);
|
||||
_materialAxisZ.SetParameterValue(_brightnessParamName, brightness);
|
||||
_materialAxisLocked.SetParameterValue(_brightnessParamName, brightness);
|
||||
|
||||
UpdateGizmoBrightness(options);
|
||||
|
||||
float opacity = options.Visual.TransformGizmoOpacity;
|
||||
_materialAxisX.SetParameterValue(_opacityParamName, opacity);
|
||||
_materialAxisY.SetParameterValue(_opacityParamName, opacity);
|
||||
_materialAxisZ.SetParameterValue(_opacityParamName, opacity);
|
||||
_materialAxisLocked.SetParameterValue(_opacityParamName, opacity);
|
||||
}
|
||||
|
||||
private void UpdateGizmoBrightness(EditorOptions options)
|
||||
{
|
||||
_isDisabled = ShouldGizmoBeLocked();
|
||||
|
||||
float brightness = _isDisabled ? options.Visual.TransformGizmoBrightnessDisabled : options.Visual.TransformGizmoBrightness;
|
||||
if (Mathf.NearEqual(brightness, (float)_materialAxisX.GetParameterValue(_brightnessParamName)))
|
||||
return;
|
||||
_materialAxisX.SetParameterValue(_brightnessParamName, brightness);
|
||||
_materialAxisY.SetParameterValue(_brightnessParamName, brightness);
|
||||
_materialAxisZ.SetParameterValue(_brightnessParamName, brightness);
|
||||
}
|
||||
|
||||
private bool ShouldGizmoBeLocked()
|
||||
{
|
||||
bool gizmoLocked = false;
|
||||
if (Editor.Instance.StateMachine.IsPlayMode && Owner is Viewport.EditorGizmoViewport)
|
||||
{
|
||||
// Block editing static scene objects in main view during play mode
|
||||
foreach (var obj in Editor.Instance.SceneEditing.Selection)
|
||||
{
|
||||
if (obj.CanTransform == false)
|
||||
{
|
||||
gizmoLocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return gizmoLocked;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -88,20 +114,8 @@ namespace FlaxEditor.Gizmo
|
||||
if (!_modelCube || !_modelCube.IsLoaded)
|
||||
return;
|
||||
|
||||
// Find out if any of the selected objects can not be moved
|
||||
bool gizmoLocked = false;
|
||||
if (Editor.Instance.StateMachine.IsPlayMode)
|
||||
{
|
||||
for (int i = 0; i < SelectionCount; i++)
|
||||
{
|
||||
var obj = GetSelectedObject(i);
|
||||
if (obj.CanTransform == false)
|
||||
{
|
||||
gizmoLocked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update the gizmo brightness every frame to ensure it updates correctly
|
||||
UpdateGizmoBrightness(Editor.Instance.Options.Options);
|
||||
|
||||
// As all axisMesh have the same pivot, add a little offset to the x axisMesh, this way SortDrawCalls is able to sort the draw order
|
||||
// https://github.com/FlaxEngine/FlaxEngine/issues/680
|
||||
@@ -136,37 +150,37 @@ namespace FlaxEditor.Gizmo
|
||||
// X axis
|
||||
Matrix.RotationY(-Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance xAxisMaterialTransform = gizmoLocked ? _materialAxisLocked : (isXAxis ? _materialAxisFocus : _materialAxisX);
|
||||
MaterialInstance xAxisMaterialTransform = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
transAxisMesh.Draw(ref renderContext, xAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Y axis
|
||||
Matrix.RotationX(Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance yAxisMaterialTransform = gizmoLocked ? _materialAxisLocked : (isYAxis ? _materialAxisFocus : _materialAxisY);
|
||||
MaterialInstance yAxisMaterialTransform = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
transAxisMesh.Draw(ref renderContext, yAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Z axis
|
||||
Matrix.RotationX(Mathf.Pi, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance zAxisMaterialTransform = gizmoLocked ? _materialAxisLocked : (isZAxis ? _materialAxisFocus : _materialAxisZ);
|
||||
MaterialInstance zAxisMaterialTransform = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
transAxisMesh.Draw(ref renderContext, zAxisMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// XY plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance xyPlaneMaterialTransform = gizmoLocked ? _materialAxisLocked : (_activeAxis == Axis.XY ? _materialAxisFocus : _materialAxisX);
|
||||
MaterialInstance xyPlaneMaterialTransform = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
cubeMesh.Draw(ref renderContext, xyPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// ZX plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance zxPlaneMaterialTransform = gizmoLocked ? _materialAxisLocked : (_activeAxis == Axis.ZX ? _materialAxisFocus : _materialAxisY);
|
||||
MaterialInstance zxPlaneMaterialTransform = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
cubeMesh.Draw(ref renderContext, zxPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// YZ plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance yzPlaneMaterialTransform = gizmoLocked ? _materialAxisLocked : (_activeAxis == Axis.YZ ? _materialAxisFocus : _materialAxisZ);
|
||||
MaterialInstance yzPlaneMaterialTransform = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
cubeMesh.Draw(ref renderContext, yzPlaneMaterialTransform, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Center sphere
|
||||
@@ -186,17 +200,17 @@ namespace FlaxEditor.Gizmo
|
||||
// X axis
|
||||
Matrix.RotationZ(Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance xAxisMaterialRotate = gizmoLocked ? _materialAxisLocked : (isXAxis ? _materialAxisFocus : _materialAxisX);
|
||||
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
rotationAxisMesh.Draw(ref renderContext, xAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Y axis
|
||||
MaterialInstance yAxisMaterialRotate = gizmoLocked ? _materialAxisLocked : (isYAxis ? _materialAxisFocus : _materialAxisY);
|
||||
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
rotationAxisMesh.Draw(ref renderContext, yAxisMaterialRotate, ref m1, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Z axis
|
||||
Matrix.RotationX(-Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance zAxisMaterialRotate = gizmoLocked ? _materialAxisLocked : (isZAxis ? _materialAxisFocus : _materialAxisZ);
|
||||
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
rotationAxisMesh.Draw(ref renderContext, zAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Center box
|
||||
@@ -216,37 +230,37 @@ namespace FlaxEditor.Gizmo
|
||||
// X axis
|
||||
Matrix.RotationY(-Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref mx1, out m3);
|
||||
MaterialInstance xAxisMaterialRotate = gizmoLocked ? _materialAxisLocked : (isXAxis ? _materialAxisFocus : _materialAxisX);
|
||||
MaterialInstance xAxisMaterialRotate = (isXAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
scaleAxisMesh.Draw(ref renderContext, xAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Y axis
|
||||
Matrix.RotationX(Mathf.PiOverTwo, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance yAxisMaterialRotate = gizmoLocked ? _materialAxisLocked : (isYAxis ? _materialAxisFocus : _materialAxisY);
|
||||
MaterialInstance yAxisMaterialRotate = (isYAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
scaleAxisMesh.Draw(ref renderContext, yAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Z axis
|
||||
Matrix.RotationX(Mathf.Pi, out m2);
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance zAxisMaterialRotate = gizmoLocked ? _materialAxisLocked : (isZAxis ? _materialAxisFocus : _materialAxisZ);
|
||||
MaterialInstance zAxisMaterialRotate = (isZAxis && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
scaleAxisMesh.Draw(ref renderContext, zAxisMaterialRotate, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// XY plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationX(Mathf.PiOverTwo), new Vector3(boxSize * boxScale, boxSize * boxScale, 0.0f));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance xyPlaneMaterialScale = gizmoLocked ? _materialAxisLocked : (_activeAxis == Axis.XY ? _materialAxisFocus : _materialAxisX);
|
||||
MaterialInstance xyPlaneMaterialScale = (_activeAxis == Axis.XY && !_isDisabled) ? _materialAxisFocus : _materialAxisX;
|
||||
cubeMesh.Draw(ref renderContext, xyPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// ZX plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.Identity, new Vector3(boxSize * boxScale, 0.0f, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance zxPlaneMaterialScale = gizmoLocked ? _materialAxisLocked : (_activeAxis == Axis.ZX ? _materialAxisFocus : _materialAxisZ);
|
||||
MaterialInstance zxPlaneMaterialScale = (_activeAxis == Axis.ZX && !_isDisabled) ? _materialAxisFocus : _materialAxisZ;
|
||||
cubeMesh.Draw(ref renderContext, zxPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// YZ plane
|
||||
m2 = Matrix.Transformation(new Vector3(boxSize, boxSize * 0.1f, boxSize), Quaternion.RotationZ(Mathf.PiOverTwo), new Vector3(0.0f, boxSize * boxScale, boxSize * boxScale));
|
||||
Matrix.Multiply(ref m2, ref m1, out m3);
|
||||
MaterialInstance yzPlaneMaterialScale = gizmoLocked ? _materialAxisLocked : (_activeAxis == Axis.YZ ? _materialAxisFocus : _materialAxisY);
|
||||
MaterialInstance yzPlaneMaterialScale = (_activeAxis == Axis.YZ && !_isDisabled) ? _materialAxisFocus : _materialAxisY;
|
||||
cubeMesh.Draw(ref renderContext, yzPlaneMaterialScale, ref m3, StaticFlags.None, true, DrawPass.Default, 0.0f, sortOrder);
|
||||
|
||||
// Center box
|
||||
|
||||
@@ -155,6 +155,16 @@ namespace FlaxEditor
|
||||
private List<Widget> _widgets;
|
||||
private Widget _activeWidget;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the view size.
|
||||
/// </summary>
|
||||
/// <param name="size">The new size.</param>
|
||||
public void SetViewSize(Float2 size)
|
||||
{
|
||||
_view.Size = size;
|
||||
_view.PerformLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if enable displaying UI editing background and grid elements.
|
||||
/// </summary>
|
||||
|
||||
@@ -54,6 +54,9 @@ namespace FlaxEditor.Modules.SourceCodeEditing
|
||||
case CodeEditorTypes.VS2022:
|
||||
Name = "Visual Studio 2022";
|
||||
break;
|
||||
case CodeEditorTypes.VS2026:
|
||||
Name = "Visual Studio 2026";
|
||||
break;
|
||||
case CodeEditorTypes.VSCode:
|
||||
Name = "Visual Studio Code";
|
||||
break;
|
||||
@@ -110,6 +113,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
|
||||
case CodeEditorTypes.VS2017:
|
||||
case CodeEditorTypes.VS2019:
|
||||
case CodeEditorTypes.VS2022:
|
||||
case CodeEditorTypes.VS2026:
|
||||
// TODO: finish dynamic files adding to the project
|
||||
//Editor.Instance.ProgressReporting.GenerateScriptsProjectFiles.RunAsync();
|
||||
break;
|
||||
|
||||
@@ -37,6 +37,53 @@ namespace FlaxEditor.Modules
|
||||
private bool _progressFailed;
|
||||
|
||||
ContextMenuSingleSelectGroup<int> _numberOfClientsGroup = new ContextMenuSingleSelectGroup<int>();
|
||||
|
||||
/// <summary>
|
||||
/// Defines a viewport scaling option.
|
||||
/// </summary>
|
||||
public class ViewportScaleOption
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the viewport scale type.
|
||||
/// </summary>
|
||||
public enum ViewportScaleType
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolution.
|
||||
/// </summary>
|
||||
Resolution = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Aspect Ratio.
|
||||
/// </summary>
|
||||
Aspect = 1,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The name.
|
||||
/// </summary>
|
||||
public string Label;
|
||||
|
||||
/// <summary>
|
||||
/// The Type of scaling to do.
|
||||
/// </summary>
|
||||
public ViewportScaleType ScaleType;
|
||||
|
||||
/// <summary>
|
||||
/// The width and height to scale by.
|
||||
/// </summary>
|
||||
public Int2 Size;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The default viewport scaling options.
|
||||
/// </summary>
|
||||
public List<ViewportScaleOption> DefaultViewportScaleOptions = new List<ViewportScaleOption>();
|
||||
|
||||
/// <summary>
|
||||
/// The user defined viewport scaling options.
|
||||
/// </summary>
|
||||
public List<ViewportScaleOption> CustomViewportScaleOptions = new List<ViewportScaleOption>();
|
||||
|
||||
private ContextMenuButton _menuFileSaveScenes;
|
||||
private ContextMenuButton _menuFileReloadScenes;
|
||||
@@ -371,6 +418,8 @@ namespace FlaxEditor.Modules
|
||||
|
||||
// Update window background
|
||||
mainWindow.BackgroundColor = Style.Current.Background;
|
||||
|
||||
InitViewportScaleOptions();
|
||||
|
||||
InitSharedMenus();
|
||||
InitMainMenu(mainWindow);
|
||||
@@ -392,6 +441,57 @@ namespace FlaxEditor.Modules
|
||||
}
|
||||
}
|
||||
|
||||
private void InitViewportScaleOptions()
|
||||
{
|
||||
if (DefaultViewportScaleOptions.Count == 0)
|
||||
{
|
||||
DefaultViewportScaleOptions.Add(new ViewportScaleOption
|
||||
{
|
||||
Label = "Free Aspect",
|
||||
ScaleType = ViewportScaleOption.ViewportScaleType.Aspect,
|
||||
Size = new Int2(1, 1),
|
||||
});
|
||||
DefaultViewportScaleOptions.Add(new ViewportScaleOption
|
||||
{
|
||||
Label = "16:9 Aspect",
|
||||
ScaleType = ViewportScaleOption.ViewportScaleType.Aspect,
|
||||
Size = new Int2(16, 9),
|
||||
});
|
||||
DefaultViewportScaleOptions.Add(new ViewportScaleOption
|
||||
{
|
||||
Label = "16:10 Aspect",
|
||||
ScaleType = ViewportScaleOption.ViewportScaleType.Aspect,
|
||||
Size = new Int2(16, 10),
|
||||
});
|
||||
DefaultViewportScaleOptions.Add(new ViewportScaleOption
|
||||
{
|
||||
Label = "1920x1080 Resolution (Full HD)",
|
||||
ScaleType = ViewportScaleOption.ViewportScaleType.Resolution,
|
||||
Size = new Int2(1920, 1080),
|
||||
});
|
||||
DefaultViewportScaleOptions.Add(new ViewportScaleOption
|
||||
{
|
||||
Label = "2560x1440 Resolution (2K)",
|
||||
ScaleType = ViewportScaleOption.ViewportScaleType.Resolution,
|
||||
Size = new Int2(2560, 1440),
|
||||
});
|
||||
}
|
||||
|
||||
if (Editor.Instance.ProjectCache.TryGetCustomData("CustomViewportScalingOptions", out string data))
|
||||
{
|
||||
CustomViewportScaleOptions = JsonSerializer.Deserialize<List<ViewportScaleOption>>(data);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the custom viewport scaling options.
|
||||
/// </summary>
|
||||
public void SaveCustomViewportScalingOptions()
|
||||
{
|
||||
var customOptions = JsonSerializer.Serialize(CustomViewportScaleOptions);
|
||||
Editor.Instance.ProjectCache.SetCustomData("CustomViewportScalingOptions", customOptions);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnUpdate()
|
||||
{
|
||||
@@ -538,6 +638,7 @@ namespace FlaxEditor.Modules
|
||||
_menuFileGenerateScriptsProjectFiles = cm.AddButton("Generate scripts project files", inputOptions.GenerateScriptsProject, Editor.ProgressReporting.GenerateScriptsProjectFiles.RunAsync);
|
||||
_menuFileRecompileScripts = cm.AddButton("Recompile scripts", inputOptions.RecompileScripts, ScriptsBuilder.Compile);
|
||||
cm.AddSeparator();
|
||||
cm.AddButton("New project", NewProject);
|
||||
cm.AddButton("Open project...", OpenProject);
|
||||
cm.AddButton("Reload project", ReloadProject);
|
||||
cm.AddButton("Open project folder", () => FileSystem.ShowFileExplorer(Editor.Instance.GameProject.ProjectFolderPath));
|
||||
@@ -829,6 +930,17 @@ namespace FlaxEditor.Modules
|
||||
MasterPanel.Offsets = new Margin(0, 0, ToolStrip.Bottom, StatusBar.Height);
|
||||
}
|
||||
|
||||
private void NewProject()
|
||||
{
|
||||
// Ask user to create project file
|
||||
if (FileSystem.ShowSaveFileDialog(Editor.Windows.MainWindow, null, "Project files (*.flaxproj)\0*.flaxproj\0All files (*.*)\0*.*\0", false, "Create project file", out var files))
|
||||
return;
|
||||
if (files != null && files.Length > 0)
|
||||
{
|
||||
Editor.NewProject(files[0]);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenProject()
|
||||
{
|
||||
// Ask user to select project file
|
||||
@@ -1085,5 +1197,267 @@ namespace FlaxEditor.Modules
|
||||
MenuTools = null;
|
||||
MenuHelp = null;
|
||||
}
|
||||
|
||||
internal void CreateViewportSizingContextMenu(ContextMenu vsMenu, int defaultScaleActiveIndex, int customScaleActiveIndex, bool prefabViewport, Action<ViewportScaleOption> changeView, Action<int, int> changeActiveIndices)
|
||||
{
|
||||
// Add default viewport sizing options
|
||||
var defaultOptions = DefaultViewportScaleOptions;
|
||||
for (int i = 0; i < defaultOptions.Count; i++)
|
||||
{
|
||||
var viewportScale = defaultOptions[i];
|
||||
if (prefabViewport && viewportScale.ScaleType == ViewportScaleOption.ViewportScaleType.Aspect)
|
||||
continue; // Skip aspect ratio types in prefab
|
||||
var button = vsMenu.AddButton(viewportScale.Label);
|
||||
button.CloseMenuOnClick = false;
|
||||
button.Tag = viewportScale;
|
||||
|
||||
// No default index is active
|
||||
if (defaultScaleActiveIndex == -1)
|
||||
{
|
||||
button.Icon = SpriteHandle.Invalid;
|
||||
}
|
||||
// This is the active index
|
||||
else if (defaultScaleActiveIndex == i)
|
||||
{
|
||||
button.Icon = Style.Current.CheckBoxTick;
|
||||
changeView(viewportScale);
|
||||
}
|
||||
|
||||
button.Clicked += () =>
|
||||
{
|
||||
if (button.Tag == null)
|
||||
return;
|
||||
|
||||
// Reset selected icon on all buttons
|
||||
foreach (var child in vsMenu.Items)
|
||||
{
|
||||
if (child is ContextMenuButton cmb && cmb.Tag is UIModule.ViewportScaleOption v)
|
||||
{
|
||||
if (cmb == button)
|
||||
{
|
||||
button.Icon = Style.Current.CheckBoxTick;
|
||||
var index = defaultOptions.FindIndex(x => x == v);
|
||||
changeActiveIndices(index, -1); // Reset custom index because default was chosen
|
||||
changeView(v);
|
||||
}
|
||||
else if (cmb.Icon != SpriteHandle.Invalid)
|
||||
{
|
||||
cmb.Icon = SpriteHandle.Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (defaultOptions.Count != 0)
|
||||
vsMenu.AddSeparator();
|
||||
|
||||
// Add custom viewport options
|
||||
var customOptions = CustomViewportScaleOptions;
|
||||
for (int i = 0; i < customOptions.Count; i++)
|
||||
{
|
||||
var viewportScale = customOptions[i];
|
||||
if (prefabViewport && viewportScale.ScaleType == ViewportScaleOption.ViewportScaleType.Aspect)
|
||||
continue; // Skip aspect ratio types in prefab
|
||||
var childCM = vsMenu.AddChildMenu(viewportScale.Label);
|
||||
childCM.CloseMenuOnClick = false;
|
||||
childCM.Tag = viewportScale;
|
||||
|
||||
// No custom index is active
|
||||
if (customScaleActiveIndex == -1)
|
||||
{
|
||||
childCM.Icon = SpriteHandle.Invalid;
|
||||
}
|
||||
// This is the active index
|
||||
else if (customScaleActiveIndex == i)
|
||||
{
|
||||
childCM.Icon = Style.Current.CheckBoxTick;
|
||||
changeView(viewportScale);
|
||||
}
|
||||
|
||||
var applyButton = childCM.ContextMenu.AddButton("Apply");
|
||||
applyButton.Tag = childCM.Tag = viewportScale;
|
||||
applyButton.CloseMenuOnClick = false;
|
||||
applyButton.Clicked += () =>
|
||||
{
|
||||
if (childCM.Tag == null)
|
||||
return;
|
||||
|
||||
// Reset selected icon on all buttons
|
||||
foreach (var child in vsMenu.Items)
|
||||
{
|
||||
if (child is ContextMenuButton cmb && cmb.Tag is UIModule.ViewportScaleOption v)
|
||||
{
|
||||
if (child == childCM)
|
||||
{
|
||||
childCM.Icon = Style.Current.CheckBoxTick;
|
||||
var index = customOptions.FindIndex(x => x == v);
|
||||
changeActiveIndices(-1, index); // Reset default index because custom was chosen
|
||||
changeView(v);
|
||||
}
|
||||
else if (cmb.Icon != SpriteHandle.Invalid)
|
||||
{
|
||||
cmb.Icon = SpriteHandle.Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var deleteButton = childCM.ContextMenu.AddButton("Delete");
|
||||
deleteButton.CloseMenuOnClick = false;
|
||||
deleteButton.Clicked += () =>
|
||||
{
|
||||
if (childCM.Tag == null)
|
||||
return;
|
||||
|
||||
var v = (ViewportScaleOption)childCM.Tag;
|
||||
if (childCM.Icon != SpriteHandle.Invalid)
|
||||
{
|
||||
changeActiveIndices(-1, 0);
|
||||
changeView(defaultOptions[0]);
|
||||
}
|
||||
customOptions.Remove(v);
|
||||
SaveCustomViewportScalingOptions();
|
||||
vsMenu.DisposeAllItems();
|
||||
CreateViewportSizingContextMenu(vsMenu, defaultScaleActiveIndex, customScaleActiveIndex, prefabViewport, changeView, changeActiveIndices);
|
||||
vsMenu.PerformLayout();
|
||||
};
|
||||
}
|
||||
if (customOptions.Count != 0)
|
||||
vsMenu.AddSeparator();
|
||||
|
||||
// Add button
|
||||
var add = vsMenu.AddButton("Add...");
|
||||
add.CloseMenuOnClick = false;
|
||||
add.Clicked += () =>
|
||||
{
|
||||
var popup = new ContextMenuBase
|
||||
{
|
||||
Size = new Float2(230, 125),
|
||||
ClipChildren = false,
|
||||
CullChildren = false,
|
||||
};
|
||||
popup.Show(add, new Float2(add.Width, 0));
|
||||
|
||||
var nameLabel = new Label
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Name",
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
};
|
||||
nameLabel.LocalX += 10;
|
||||
nameLabel.LocalY += 10;
|
||||
|
||||
var nameTextBox = new TextBox
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
IsMultiline = false,
|
||||
};
|
||||
nameTextBox.LocalX += 100;
|
||||
nameTextBox.LocalY += 10;
|
||||
|
||||
var typeLabel = new Label
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Type",
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
};
|
||||
typeLabel.LocalX += 10;
|
||||
typeLabel.LocalY += 35;
|
||||
|
||||
var typeDropdown = new Dropdown
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Items = { "Aspect", "Resolution" },
|
||||
SelectedItem = "Aspect",
|
||||
Visible = !prefabViewport,
|
||||
Width = nameTextBox.Width
|
||||
};
|
||||
typeDropdown.LocalY += 35;
|
||||
typeDropdown.LocalX += 100;
|
||||
|
||||
var whLabel = new Label
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Width & Height",
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
};
|
||||
whLabel.LocalX += 10;
|
||||
whLabel.LocalY += 60;
|
||||
|
||||
var wValue = new IntValueBox(16)
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
MinValue = 1,
|
||||
Width = 55,
|
||||
};
|
||||
wValue.LocalY += 60;
|
||||
wValue.LocalX += 100;
|
||||
|
||||
var hValue = new IntValueBox(9)
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
MinValue = 1,
|
||||
Width = 55,
|
||||
};
|
||||
hValue.LocalY += 60;
|
||||
hValue.LocalX += 165;
|
||||
|
||||
var submitButton = new Button
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Submit",
|
||||
Width = 70,
|
||||
};
|
||||
submitButton.LocalX += 40;
|
||||
submitButton.LocalY += 90;
|
||||
submitButton.Clicked += () =>
|
||||
{
|
||||
Enum.TryParse(typeDropdown.SelectedItem, out ViewportScaleOption.ViewportScaleType type);
|
||||
if (prefabViewport)
|
||||
type = ViewportScaleOption.ViewportScaleType.Resolution;
|
||||
|
||||
var combineString = type == ViewportScaleOption.ViewportScaleType.Aspect ? ":" : "x";
|
||||
var name = nameTextBox.Text + " (" + wValue.Value + combineString + hValue.Value + ") " + typeDropdown.SelectedItem;
|
||||
var newViewportOption = new ViewportScaleOption
|
||||
{
|
||||
ScaleType = type,
|
||||
Label = name,
|
||||
Size = new Int2(wValue.Value, hValue.Value),
|
||||
};
|
||||
|
||||
customOptions.Add(newViewportOption);
|
||||
SaveCustomViewportScalingOptions();
|
||||
vsMenu.DisposeAllItems();
|
||||
CreateViewportSizingContextMenu(vsMenu, defaultScaleActiveIndex, customScaleActiveIndex, prefabViewport, changeView, changeActiveIndices);
|
||||
vsMenu.PerformLayout();
|
||||
};
|
||||
|
||||
var cancelButton = new Button
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Cancel",
|
||||
Width = 70,
|
||||
};
|
||||
cancelButton.LocalX += 120;
|
||||
cancelButton.LocalY += 90;
|
||||
cancelButton.Clicked += () =>
|
||||
{
|
||||
nameTextBox.Clear();
|
||||
typeDropdown.SelectedItem = "Aspect";
|
||||
hValue.Value = 9;
|
||||
wValue.Value = 16;
|
||||
popup.Hide();
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,5 +150,26 @@ namespace FlaxEditor.Options
|
||||
[DefaultValue(typeof(Color), "0.5,0.5,0.5,1.0")]
|
||||
[EditorDisplay("Grid"), EditorOrder(310), Tooltip("The color for the viewport grid.")]
|
||||
public Color ViewportGridColor { get; set; } = new Color(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum size used for viewport icons.
|
||||
/// </summary>
|
||||
[DefaultValue(7.0f), Limit(1.0f, 1000.0f, 5.0f)]
|
||||
[EditorDisplay("Viewport Icons"), EditorOrder(400)]
|
||||
public float IconsMinimumSize { get; set; } = 7.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum size used for viewport icons.
|
||||
/// </summary>
|
||||
[DefaultValue(30.0f), Limit(1.0f, 1000.0f, 5.0f)]
|
||||
[EditorDisplay("Viewport Icons"), EditorOrder(410)]
|
||||
public float IconsMaximumSize { get; set; } = 30.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the distance towards the camera at which the max icon scale will be applied. Set to 0 to disable scaling the icons based on the distance to the camera.
|
||||
/// </summary>
|
||||
[DefaultValue(1000.0f), Limit(0.0f, 20000.0f, 5.0f)]
|
||||
[EditorDisplay("Viewport Icons"), EditorOrder(410)]
|
||||
public float MaxSizeDistance { get; set; } = 1000.0f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,13 @@ namespace FlaxEditor.Options
|
||||
[EditorDisplay("Transform Gizmo", "Gizmo Opacity"), EditorOrder(211)]
|
||||
public float TransformGizmoOpacity { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set a value indicating how bright the transform gizmo is when it is disabled, for example when one of the selected actors is static in play mode. Use a value of 0 to make the gizmo fully gray. Value over 1 will result in the gizmo emitting light.
|
||||
/// </summary>
|
||||
[DefaultValue(0.25f), Range(0f, 5f)]
|
||||
[EditorDisplay("Transform Gizmo", "Disabled Gizmo Brightness"), EditorOrder(212)]
|
||||
public float TransformGizmoBrightnessDisabled { get; set; } = 0.25f;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether enable MSAA for DebugDraw primitives rendering. Helps with pixel aliasing but reduces performance.
|
||||
/// </summary>
|
||||
|
||||
@@ -62,6 +62,11 @@ API_ENUM(Namespace="FlaxEditor", Attributes="HideInEditor") enum class CodeEdito
|
||||
/// </summary>
|
||||
VS2022,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio 2026
|
||||
/// </summary>
|
||||
VS2026,
|
||||
|
||||
/// <summary>
|
||||
/// Visual Studio Code
|
||||
/// </summary>
|
||||
|
||||
@@ -43,6 +43,9 @@ VisualStudioEditor::VisualStudioEditor(VisualStudioVersion version, const String
|
||||
case VisualStudioVersion::VS2022:
|
||||
_type = CodeEditorTypes::VS2022;
|
||||
break;
|
||||
case VisualStudioVersion::VS2026:
|
||||
_type = CodeEditorTypes::VS2026;
|
||||
break;
|
||||
default: CRASH;
|
||||
break;
|
||||
}
|
||||
@@ -70,6 +73,9 @@ void VisualStudioEditor::FindEditors(Array<CodeEditor*>* output)
|
||||
VisualStudioVersion version;
|
||||
switch (info.VersionMajor)
|
||||
{
|
||||
case 18:
|
||||
version = VisualStudioVersion::VS2026;
|
||||
break;
|
||||
case 17:
|
||||
version = VisualStudioVersion::VS2022;
|
||||
break;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Microsoft Visual Studio version types
|
||||
/// </summary>
|
||||
DECLARE_ENUM_8(VisualStudioVersion, VS2008, VS2010, VS2012, VS2013, VS2015, VS2017, VS2019, VS2022);
|
||||
DECLARE_ENUM_9(VisualStudioVersion, VS2008, VS2010, VS2012, VS2013, VS2015, VS2017, VS2019, VS2022, VS2026);
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of code editor utility that is using Microsoft Visual Studio.
|
||||
|
||||
@@ -229,20 +229,20 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, Box startBox)
|
||||
protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, List<Box> startBoxes)
|
||||
{
|
||||
// Check if show additional nodes in the current surface context
|
||||
if (activeCM != _cmStateMachineMenu)
|
||||
{
|
||||
_nodesCache.Get(activeCM);
|
||||
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBox);
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBoxes);
|
||||
|
||||
activeCM.VisibleChanged += OnActiveContextMenuVisibleChanged;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBox);
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBoxes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,12 +101,12 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, Box startBox)
|
||||
protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, List<Box> startBoxes)
|
||||
{
|
||||
activeCM.ShowExpanded = true;
|
||||
_nodesCache.Get(activeCM);
|
||||
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBox);
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBoxes);
|
||||
|
||||
activeCM.VisibleChanged += OnActiveContextMenuVisibleChanged;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
/// Visject context menu item clicked delegate.
|
||||
/// </summary>
|
||||
/// <param name="clickedItem">The item that was clicked</param>
|
||||
/// <param name="selectedBox">The currently user-selected box. Can be null.</param>
|
||||
public delegate void ItemClickedDelegate(VisjectCMItem clickedItem, Elements.Box selectedBox);
|
||||
/// <param name="selectedBoxes">The currently user-selected boxes. Can be empty/ null.</param>
|
||||
public delegate void ItemClickedDelegate(VisjectCMItem clickedItem, List<Elements.Box> selectedBoxes);
|
||||
|
||||
/// <summary>
|
||||
/// Visject Surface node archetype spawn ability checking delegate.
|
||||
@@ -53,7 +53,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
private Panel _panel1;
|
||||
private VerticalPanel _groupsPanel;
|
||||
private readonly ParameterGetterDelegate _parametersGetter;
|
||||
private Elements.Box _selectedBox;
|
||||
private List<Elements.Box> _selectedBoxes = new List<Elements.Box>();
|
||||
private NodeArchetype _parameterGetNodeArchetype;
|
||||
private NodeArchetype _parameterSetNodeArchetype;
|
||||
|
||||
@@ -411,7 +411,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
if (!IsLayoutLocked)
|
||||
{
|
||||
group.UnlockChildrenRecursive();
|
||||
if (_contextSensitiveSearchEnabled && _selectedBox != null)
|
||||
// TODO: Improve filtering to be based on boxes with the most common things instead of first box
|
||||
if (_contextSensitiveSearchEnabled && _selectedBoxes[0] != null)
|
||||
UpdateFilters();
|
||||
else
|
||||
SortGroups();
|
||||
@@ -425,7 +426,8 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
}
|
||||
else if (_contextSensitiveSearchEnabled)
|
||||
{
|
||||
group.EvaluateVisibilityWithBox(_selectedBox);
|
||||
// TODO: Filtering could be improved here as well
|
||||
group.EvaluateVisibilityWithBox(_selectedBoxes[0]);
|
||||
}
|
||||
|
||||
Profiler.EndEvent();
|
||||
@@ -461,7 +463,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
};
|
||||
}
|
||||
if (_contextSensitiveSearchEnabled)
|
||||
group.EvaluateVisibilityWithBox(_selectedBox);
|
||||
group.EvaluateVisibilityWithBox(_selectedBoxes[0]);
|
||||
group.SortChildren();
|
||||
if (ShowExpanded)
|
||||
group.Open(false);
|
||||
@@ -474,7 +476,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
|
||||
if (!isLayoutLocked)
|
||||
{
|
||||
if (_contextSensitiveSearchEnabled && _selectedBox != null)
|
||||
if (_contextSensitiveSearchEnabled && _selectedBoxes[0] != null)
|
||||
UpdateFilters();
|
||||
else
|
||||
SortGroups();
|
||||
@@ -583,7 +585,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
|
||||
private void UpdateFilters()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchBox.Text) && _selectedBox == null)
|
||||
if (string.IsNullOrEmpty(_searchBox.Text) && _selectedBoxes[0] == null)
|
||||
{
|
||||
ResetView();
|
||||
Profiler.EndEvent();
|
||||
@@ -592,7 +594,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
|
||||
// Update groups
|
||||
LockChildrenRecursive();
|
||||
var contextSensitiveSelectedBox = _contextSensitiveSearchEnabled ? _selectedBox : null;
|
||||
var contextSensitiveSelectedBox = _contextSensitiveSearchEnabled && _selectedBoxes.Count > 0 ? _selectedBoxes[0] : null;
|
||||
for (int i = 0; i < _groups.Count; i++)
|
||||
{
|
||||
_groups[i].UpdateFilter(_searchBox.Text, contextSensitiveSelectedBox);
|
||||
@@ -640,7 +642,7 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
public void OnClickItem(VisjectCMItem item)
|
||||
{
|
||||
Hide();
|
||||
ItemClicked?.Invoke(item, _selectedBox);
|
||||
ItemClicked?.Invoke(item, _selectedBoxes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -666,12 +668,12 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
for (int i = 0; i < _groups.Count; i++)
|
||||
{
|
||||
_groups[i].ResetView();
|
||||
if (_contextSensitiveSearchEnabled)
|
||||
_groups[i].EvaluateVisibilityWithBox(_selectedBox);
|
||||
if (_contextSensitiveSearchEnabled && _selectedBoxes.Count > 0)
|
||||
_groups[i].EvaluateVisibilityWithBox(_selectedBoxes[0]);
|
||||
}
|
||||
UnlockChildrenRecursive();
|
||||
|
||||
if (_contextSensitiveSearchEnabled && _selectedBox != null)
|
||||
if (_contextSensitiveSearchEnabled && _selectedBoxes.Count > 0 && _selectedBoxes[0] != null)
|
||||
UpdateFilters();
|
||||
else
|
||||
SortGroups();
|
||||
@@ -772,10 +774,10 @@ namespace FlaxEditor.Surface.ContextMenu
|
||||
/// </summary>
|
||||
/// <param name="parent">Parent control to attach to it.</param>
|
||||
/// <param name="location">Popup menu origin location in parent control coordinates.</param>
|
||||
/// <param name="startBox">The currently selected box that the new node will get connected to. Can be null</param>
|
||||
public void Show(Control parent, Float2 location, Elements.Box startBox)
|
||||
/// <param name="startBoxes">The currently selected boxes that the new node will get connected to. Can be empty/ null</param>
|
||||
public void Show(Control parent, Float2 location, List<Elements.Box> startBoxes)
|
||||
{
|
||||
_selectedBox = startBox;
|
||||
_selectedBoxes = startBoxes;
|
||||
base.Show(parent, location);
|
||||
}
|
||||
|
||||
|
||||
@@ -544,35 +544,39 @@ namespace FlaxEditor.Surface.Elements
|
||||
public override void OnMouseLeave()
|
||||
{
|
||||
if (_originalTooltipText != null)
|
||||
{
|
||||
TooltipText = _originalTooltipText;
|
||||
}
|
||||
if (_isMouseDown)
|
||||
{
|
||||
_isMouseDown = false;
|
||||
if (Surface.CanEdit)
|
||||
{
|
||||
if (!IsOutput && HasSingleConnection)
|
||||
if (IsOutput && Input.GetKey(KeyboardKeys.Control))
|
||||
{
|
||||
var connectedBox = Connections[0];
|
||||
List<Box> connectedBoxes = new List<Box>(Connections);
|
||||
|
||||
for (int i = 0; i < connectedBoxes.Count; i++)
|
||||
{
|
||||
BreakConnection(connectedBoxes[i]);
|
||||
Surface.ConnectingStart(connectedBoxes[i], true);
|
||||
}
|
||||
}
|
||||
else if (!IsOutput && HasSingleConnection)
|
||||
{
|
||||
var otherBox = Connections[0];
|
||||
if (Surface.Undo != null && Surface.Undo.Enabled)
|
||||
{
|
||||
var action = new ConnectBoxesAction((InputBox)this, (OutputBox)connectedBox, false);
|
||||
BreakConnection(connectedBox);
|
||||
var action = new ConnectBoxesAction((InputBox)this, (OutputBox)otherBox, false);
|
||||
BreakConnection(otherBox);
|
||||
action.End();
|
||||
Surface.AddBatchedUndoAction(action);
|
||||
Surface.MarkAsEdited();
|
||||
}
|
||||
else
|
||||
{
|
||||
BreakConnection(connectedBox);
|
||||
}
|
||||
Surface.ConnectingStart(connectedBox);
|
||||
BreakConnection(otherBox);
|
||||
Surface.ConnectingStart(otherBox);
|
||||
}
|
||||
else
|
||||
{
|
||||
Surface.ConnectingStart(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
base.OnMouseLeave();
|
||||
|
||||
@@ -917,7 +917,7 @@ namespace FlaxEditor.Surface
|
||||
/// <inheritdoc />
|
||||
public override bool OnTestTooltipOverControl(ref Float2 location)
|
||||
{
|
||||
return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsBoxSelecting;
|
||||
return _headerRect.Contains(ref location) && ShowTooltip && !Surface.IsConnecting && !Surface.IsSelecting;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1075,7 +1075,7 @@ namespace FlaxEditor.Surface
|
||||
|
||||
// Header
|
||||
var headerColor = style.BackgroundHighlighted;
|
||||
if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsBoxSelecting)
|
||||
if (_headerRect.Contains(ref _mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting)
|
||||
headerColor *= 1.07f;
|
||||
Render2D.FillRectangle(_headerRect, headerColor);
|
||||
Render2D.DrawText(style.FontLarge, Title, _headerRect, style.Foreground, TextAlignment.Center, TextAlignment.Center);
|
||||
@@ -1083,7 +1083,7 @@ namespace FlaxEditor.Surface
|
||||
// Close button
|
||||
if ((Archetype.Flags & NodeFlags.NoCloseButton) == 0 && Surface.CanEdit)
|
||||
{
|
||||
bool highlightClose = _closeButtonRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsBoxSelecting;
|
||||
bool highlightClose = _closeButtonRect.Contains(_mousePosition) && !Surface.IsConnecting && !Surface.IsSelecting;
|
||||
Render2D.DrawSprite(style.Cross, _closeButtonRect, highlightClose ? style.Foreground : style.ForegroundGrey);
|
||||
}
|
||||
|
||||
@@ -1133,7 +1133,7 @@ namespace FlaxEditor.Surface
|
||||
return true;
|
||||
|
||||
// Close/ delete
|
||||
bool canDelete = !Surface.IsConnecting && !Surface.WasBoxSelecting && !Surface.WasMovingSelection;
|
||||
bool canDelete = !Surface.IsConnecting && !Surface.WasSelecting && !Surface.WasMovingSelection;
|
||||
if (button == MouseButton.Left && canDelete && (Archetype.Flags & NodeFlags.NoCloseButton) == 0 && _closeButtonRect.Contains(ref location))
|
||||
{
|
||||
Surface.Delete(this);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright (c) Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEditor.Surface.Elements;
|
||||
using FlaxEngine;
|
||||
|
||||
namespace FlaxEditor.Surface
|
||||
@@ -233,11 +235,15 @@ namespace FlaxEditor.Surface
|
||||
/// Begins connecting surface objects action.
|
||||
/// </summary>
|
||||
/// <param name="instigator">The connection instigator (eg. start box).</param>
|
||||
public void ConnectingStart(IConnectionInstigator instigator)
|
||||
/// <param name="additive">If the instigator should be added to the list of instigators.</param>
|
||||
public void ConnectingStart(IConnectionInstigator instigator, bool additive = false)
|
||||
{
|
||||
if (instigator != null && instigator != _connectionInstigator)
|
||||
if (instigator != null && instigator != _connectionInstigators)
|
||||
{
|
||||
_connectionInstigator = instigator;
|
||||
if (!additive)
|
||||
_connectionInstigators.Clear();
|
||||
|
||||
_connectionInstigators.Add(instigator);
|
||||
StartMouseCapture();
|
||||
}
|
||||
}
|
||||
@@ -257,22 +263,30 @@ namespace FlaxEditor.Surface
|
||||
/// <param name="end">The end object (eg. end box).</param>
|
||||
public void ConnectingEnd(IConnectionInstigator end)
|
||||
{
|
||||
// Ensure that there was a proper start box
|
||||
if (_connectionInstigator == null)
|
||||
// Ensure that there is at least one connection instigator
|
||||
if (_connectionInstigators.Count == 0)
|
||||
return;
|
||||
|
||||
var start = _connectionInstigator;
|
||||
_connectionInstigator = null;
|
||||
|
||||
// Check if boxes are different and end box is specified
|
||||
if (start == end || end == null)
|
||||
return;
|
||||
|
||||
// Connect them
|
||||
if (start.CanConnectWith(end))
|
||||
List<IConnectionInstigator> instigators = new List<IConnectionInstigator>(_connectionInstigators);
|
||||
for (int i = 0; i < instigators.Count; i++)
|
||||
{
|
||||
start.Connect(end);
|
||||
var start = instigators[i];
|
||||
|
||||
// Check if boxes are different and end box is specified
|
||||
if (start == end || end == null)
|
||||
return;
|
||||
|
||||
// Properly handle connecting to a socket that already has a connection
|
||||
if (end is Box e && !e.IsOutput && start is Box s && e.AreConnected(s))
|
||||
e.BreakConnection(s);
|
||||
|
||||
// Connect them
|
||||
if (start.CanConnectWith(end))
|
||||
start.Connect(end);
|
||||
}
|
||||
|
||||
// Reset instigator list
|
||||
_connectionInstigators.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,10 +261,10 @@ namespace FlaxEditor.Surface
|
||||
/// </summary>
|
||||
/// <param name="activeCM">The active context menu to show.</param>
|
||||
/// <param name="location">The display location on the surface control.</param>
|
||||
/// <param name="startBox">The start box.</param>
|
||||
protected virtual void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, Box startBox)
|
||||
/// <param name="startBoxes">The start boxes.</param>
|
||||
protected virtual void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, List<Box> startBoxes)
|
||||
{
|
||||
activeCM.Show(this, location, startBox);
|
||||
activeCM.Show(this, location, startBoxes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -298,8 +298,10 @@ namespace FlaxEditor.Surface
|
||||
|
||||
_cmStartPos = location;
|
||||
|
||||
// Offset added in case the user doesn't like the box and wants to quickly get rid of it by clicking
|
||||
OnShowPrimaryMenu(_activeVisjectCM, _cmStartPos + ContextMenuOffset, _connectionInstigator as Box);
|
||||
List<Box> startBoxes = new List<Box>(_connectionInstigators.Where(c => c is Box).Cast<Box>());
|
||||
|
||||
// Position offset added so the user can quickly close the menu by clicking
|
||||
OnShowPrimaryMenu(_activeVisjectCM, _cmStartPos + ContextMenuOffset, startBoxes);
|
||||
|
||||
if (!string.IsNullOrEmpty(input))
|
||||
{
|
||||
@@ -513,17 +515,15 @@ namespace FlaxEditor.Surface
|
||||
private void OnPrimaryMenuVisibleChanged(Control primaryMenu)
|
||||
{
|
||||
if (!primaryMenu.Visible)
|
||||
{
|
||||
_connectionInstigator = null;
|
||||
}
|
||||
_connectionInstigators.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles Visject CM item click event by spawning the selected item.
|
||||
/// </summary>
|
||||
/// <param name="visjectCmItem">The item.</param>
|
||||
/// <param name="selectedBox">The selected box.</param>
|
||||
protected virtual void OnPrimaryMenuButtonClick(VisjectCMItem visjectCmItem, Box selectedBox)
|
||||
/// <param name="selectedBoxes">The selected boxes.</param>
|
||||
protected virtual void OnPrimaryMenuButtonClick(VisjectCMItem visjectCmItem, List<Box> selectedBoxes)
|
||||
{
|
||||
if (!CanEdit)
|
||||
return;
|
||||
@@ -550,34 +550,36 @@ namespace FlaxEditor.Surface
|
||||
// Auto select new node
|
||||
Select(node);
|
||||
|
||||
if (selectedBox != null)
|
||||
for (int i = 0; i < selectedBoxes.Count; i++)
|
||||
{
|
||||
Box endBox = null;
|
||||
foreach (var box in node.GetBoxes().Where(box => box.IsOutput != selectedBox.IsOutput))
|
||||
Box currentBox = selectedBoxes[i];
|
||||
if (currentBox != null)
|
||||
{
|
||||
if (selectedBox.IsOutput)
|
||||
Box endBox = null;
|
||||
foreach (var box in node.GetBoxes().Where(box => box.IsOutput != currentBox.IsOutput))
|
||||
{
|
||||
if (box.CanUseType(selectedBox.CurrentType))
|
||||
if (currentBox.IsOutput)
|
||||
{
|
||||
endBox = box;
|
||||
break;
|
||||
if (box.CanUseType(currentBox.CurrentType))
|
||||
{
|
||||
endBox = box;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedBox.CanUseType(box.CurrentType))
|
||||
else
|
||||
{
|
||||
endBox = box;
|
||||
break;
|
||||
if (currentBox.CanUseType(box.CurrentType))
|
||||
{
|
||||
endBox = box;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (endBox == null && selectedBox.CanUseType(box.CurrentType))
|
||||
{
|
||||
endBox = box;
|
||||
if (endBox == null && currentBox.CanUseType(box.CurrentType))
|
||||
endBox = box;
|
||||
}
|
||||
TryConnect(currentBox, endBox);
|
||||
}
|
||||
TryConnect(selectedBox, endBox);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,13 +595,8 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
// If the user is patiently waiting for his box to get connected to the newly created one fulfill his wish!
|
||||
|
||||
_connectionInstigator = startBox;
|
||||
|
||||
if (!IsConnecting)
|
||||
{
|
||||
ConnectingStart(startBox);
|
||||
}
|
||||
ConnectingEnd(endBox);
|
||||
|
||||
// Smart-Select next box
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) Wojciech Figat. All rights reserved.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using FlaxEditor.Surface.Elements;
|
||||
using FlaxEngine;
|
||||
|
||||
@@ -126,40 +127,45 @@ namespace FlaxEditor.Surface
|
||||
/// <remarks>Called only when user is connecting nodes.</remarks>
|
||||
protected virtual void DrawConnectingLine()
|
||||
{
|
||||
// Get start position
|
||||
var startPos = _connectionInstigator.ConnectionOrigin;
|
||||
|
||||
// Check if mouse is over any of box
|
||||
var cmVisible = _activeVisjectCM != null && _activeVisjectCM.Visible;
|
||||
var endPos = cmVisible ? _rootControl.PointFromParent(ref _cmStartPos) : _rootControl.PointFromParent(ref _mousePos);
|
||||
Color lineColor = Style.Colors.Connecting;
|
||||
if (_lastInstigatorUnderMouse != null && !cmVisible)
|
||||
{
|
||||
// Check if can connect objects
|
||||
bool canConnect = _connectionInstigator.CanConnectWith(_lastInstigatorUnderMouse);
|
||||
lineColor = canConnect ? Style.Colors.ConnectingValid : Style.Colors.ConnectingInvalid;
|
||||
endPos = _lastInstigatorUnderMouse.ConnectionOrigin;
|
||||
}
|
||||
|
||||
Float2 actualStartPos = startPos;
|
||||
Float2 actualEndPos = endPos;
|
||||
|
||||
if (_connectionInstigator is Archetypes.Tools.RerouteNode)
|
||||
List<IConnectionInstigator> instigators = new List<IConnectionInstigator>(_connectionInstigators);
|
||||
for (int i = 0; i < instigators.Count; i++)
|
||||
{
|
||||
if (endPos.X < startPos.X && _lastInstigatorUnderMouse is null or Box { IsOutput: true })
|
||||
IConnectionInstigator currentInstigator = instigators[i];
|
||||
Float2 currentStartPosition = currentInstigator.ConnectionOrigin;
|
||||
|
||||
// Check if mouse is over any box
|
||||
if (_lastInstigatorUnderMouse != null && !cmVisible)
|
||||
{
|
||||
// Check if can connect objects
|
||||
bool canConnect = currentInstigator.CanConnectWith(_lastInstigatorUnderMouse);
|
||||
lineColor = canConnect ? Style.Colors.ConnectingValid : Style.Colors.ConnectingInvalid;
|
||||
endPos = _lastInstigatorUnderMouse.ConnectionOrigin;
|
||||
}
|
||||
|
||||
Float2 actualStartPos = currentStartPosition;
|
||||
Float2 actualEndPos = endPos;
|
||||
|
||||
if (currentInstigator is Archetypes.Tools.RerouteNode)
|
||||
{
|
||||
if (endPos.X < currentStartPosition.X && _lastInstigatorUnderMouse is null or Box { IsOutput: true })
|
||||
{
|
||||
actualStartPos = endPos;
|
||||
actualEndPos = currentStartPosition;
|
||||
}
|
||||
}
|
||||
else if (currentInstigator is Box { IsOutput: false })
|
||||
{
|
||||
actualStartPos = endPos;
|
||||
actualEndPos = startPos;
|
||||
actualEndPos = currentStartPosition;
|
||||
}
|
||||
}
|
||||
else if (_connectionInstigator is Box { IsOutput: false })
|
||||
{
|
||||
actualStartPos = endPos;
|
||||
actualEndPos = startPos;
|
||||
}
|
||||
|
||||
// Draw connection
|
||||
_connectionInstigator.DrawConnectingLine(ref actualStartPos, ref actualEndPos, ref lineColor);
|
||||
// Draw connection
|
||||
currentInstigator.DrawConnectingLine(ref actualStartPos, ref actualEndPos, ref lineColor);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -226,10 +232,10 @@ namespace FlaxEditor.Surface
|
||||
_rootControl.DrawComments();
|
||||
|
||||
// Reset input flags here because this is the closest to Update we have
|
||||
WasBoxSelecting = IsBoxSelecting;
|
||||
WasSelecting = IsSelecting;
|
||||
WasMovingSelection = IsMovingSelection;
|
||||
|
||||
if (IsBoxSelecting)
|
||||
if (IsSelecting)
|
||||
{
|
||||
DrawSelection();
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ namespace FlaxEditor.Surface
|
||||
if (_leftMouseDown)
|
||||
{
|
||||
// Connecting
|
||||
if (_connectionInstigator != null)
|
||||
if (_connectionInstigators.Count > 0)
|
||||
{
|
||||
}
|
||||
// Moving
|
||||
@@ -462,7 +462,7 @@ namespace FlaxEditor.Surface
|
||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||
{
|
||||
// Check if user is connecting boxes
|
||||
if (_connectionInstigator != null)
|
||||
if (_connectionInstigators.Count > 0)
|
||||
return true;
|
||||
|
||||
// Base
|
||||
@@ -608,7 +608,7 @@ namespace FlaxEditor.Surface
|
||||
_movingNodesDelta = Float2.Zero;
|
||||
}
|
||||
// Connecting
|
||||
else if (_connectionInstigator != null)
|
||||
else if (_connectionInstigators.Count > 0)
|
||||
{
|
||||
}
|
||||
// Selecting
|
||||
@@ -680,7 +680,7 @@ namespace FlaxEditor.Surface
|
||||
ShowPrimaryMenu(_cmStartPos);
|
||||
}
|
||||
// Letting go of a connection or right clicking while creating a connection
|
||||
else if (!_isMovingSelection && _connectionInstigator != null && !IsPrimaryMenuOpened)
|
||||
else if (!_isMovingSelection && _connectionInstigators.Count > 0 && !IsPrimaryMenuOpened)
|
||||
{
|
||||
_cmStartPos = location;
|
||||
Cursor = CursorType.Default;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace FlaxEditor.Surface
|
||||
Enabled = false;
|
||||
|
||||
// Clean data
|
||||
_connectionInstigator = null;
|
||||
_connectionInstigators.Clear();
|
||||
_lastInstigatorUnderMouse = null;
|
||||
|
||||
var failed = RootContext.Load();
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// The connection start.
|
||||
/// </summary>
|
||||
protected IConnectionInstigator _connectionInstigator;
|
||||
protected List<IConnectionInstigator> _connectionInstigators = new List<IConnectionInstigator>();
|
||||
|
||||
/// <summary>
|
||||
/// The last connection instigator under mouse.
|
||||
@@ -232,19 +232,19 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether user is box selecting nodes.
|
||||
/// Gets a value indicating whether user is selecting nodes.
|
||||
/// </summary>
|
||||
public bool IsBoxSelecting => _leftMouseDown && !_isMovingSelection && _connectionInstigator == null;
|
||||
public bool IsSelecting => _leftMouseDown && !_isMovingSelection && _connectionInstigators.Count == 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether user was previously box selecting nodes.
|
||||
/// Gets a value indicating whether user was previously selecting nodes.
|
||||
/// </summary>
|
||||
public bool WasBoxSelecting { get; private set; }
|
||||
public bool WasSelecting { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether user is moving selected nodes.
|
||||
/// </summary>
|
||||
public bool IsMovingSelection => _leftMouseDown && _isMovingSelection && _connectionInstigator == null;
|
||||
public bool IsMovingSelection => _leftMouseDown && _isMovingSelection && _connectionInstigators.Count == 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether user was previously moving selected nodes.
|
||||
@@ -254,7 +254,7 @@ namespace FlaxEditor.Surface
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether user is connecting nodes.
|
||||
/// </summary>
|
||||
public bool IsConnecting => _connectionInstigator != null;
|
||||
public bool IsConnecting => _connectionInstigators.Count > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the left mouse button is down.
|
||||
|
||||
@@ -212,7 +212,7 @@ namespace FlaxEditor.Surface
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, Box startBox)
|
||||
protected override void OnShowPrimaryMenu(VisjectCM activeCM, Float2 location, List<Box> startBoxes)
|
||||
{
|
||||
// Update nodes for method overrides
|
||||
Profiler.BeginEvent("Overrides");
|
||||
@@ -268,7 +268,7 @@ namespace FlaxEditor.Surface
|
||||
// Update nodes for invoke methods (async)
|
||||
_nodesCache.Get(activeCM);
|
||||
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBox);
|
||||
base.OnShowPrimaryMenu(activeCM, location, startBoxes);
|
||||
|
||||
activeCM.VisibleChanged += OnActiveContextMenuVisibleChanged;
|
||||
}
|
||||
|
||||
@@ -212,6 +212,10 @@ namespace FlaxEditor.Utilities
|
||||
if (value is FlaxEngine.Object)
|
||||
return value;
|
||||
|
||||
// For custom types use interface
|
||||
if (value is ICloneable clonable)
|
||||
return clonable.Clone();
|
||||
|
||||
// For objects (eg. arrays) we need to clone them to prevent editing default/reference value within editor
|
||||
if (value != null && (!value.GetType().IsValueType || !value.GetType().IsClass))
|
||||
{
|
||||
@@ -548,6 +552,26 @@ namespace FlaxEditor.Utilities
|
||||
return arr;
|
||||
}
|
||||
|
||||
internal static void StructureToByteArray(object value, int valueSize, IntPtr tempBuffer, byte[] dataBuffer)
|
||||
{
|
||||
var valueType = value.GetType();
|
||||
if (valueType.IsEnum)
|
||||
{
|
||||
var ptr = FlaxEngine.Interop.NativeInterop.ValueTypeUnboxer.GetPointer(value, valueType);
|
||||
FlaxEngine.Utils.MemoryCopy(tempBuffer, ptr, (ulong)valueSize);
|
||||
}
|
||||
else
|
||||
Marshal.StructureToPtr(value, tempBuffer, true);
|
||||
Marshal.Copy(tempBuffer, dataBuffer, 0, valueSize);
|
||||
}
|
||||
|
||||
internal static object ByteArrayToStructure(IntPtr valuePtr, Type valueType, int valueSize)
|
||||
{
|
||||
if (valueType.IsEnum)
|
||||
return FlaxEngine.Interop.NativeInterop.MarshalToManaged(valuePtr, valueType);
|
||||
return Marshal.PtrToStructure(valuePtr, valueType);
|
||||
}
|
||||
|
||||
internal static unsafe string ReadStr(this BinaryReader stream, int check)
|
||||
{
|
||||
int length = stream.ReadInt32();
|
||||
|
||||
@@ -66,13 +66,14 @@ public:
|
||||
|
||||
ViewportIconsRendererService ViewportIconsRendererServiceInstance;
|
||||
float ViewportIconsRenderer::Scale = 1.0f;
|
||||
Real ViewportIconsRenderer::MinSize = 7.0f;
|
||||
Real ViewportIconsRenderer::MaxSize = 30.0f;
|
||||
Real ViewportIconsRenderer::MaxSizeDistance = 1000.0f;
|
||||
|
||||
void ViewportIconsRenderer::GetBounds(const Vector3& position, const Vector3& viewPosition, BoundingSphere& bounds)
|
||||
{
|
||||
constexpr Real minSize = 7.0;
|
||||
constexpr Real maxSize = 30.0;
|
||||
Real scale = Math::Square(Vector3::Distance(position, viewPosition) / 1000.0f);
|
||||
Real radius = minSize + Math::Min<Real>(scale, 1.0f) * (maxSize - minSize);
|
||||
Real scale = Math::Square(Vector3::Distance(position, viewPosition) / MaxSizeDistance);
|
||||
Real radius = MinSize + Math::Min<Real>(scale, 1.0f) * (MaxSize - MinSize);
|
||||
bounds = BoundingSphere(position, radius * Scale);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,21 @@ public:
|
||||
/// </summary>
|
||||
API_FIELD() static float Scale;
|
||||
|
||||
/// <summary>
|
||||
/// The minimum size of the icons.
|
||||
/// </summary>
|
||||
API_FIELD() static Real MinSize;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum size of the icons.
|
||||
/// </summary>
|
||||
API_FIELD() static Real MaxSize;
|
||||
|
||||
/// <summary>
|
||||
/// The distance to the camera at which the icons will be drawn at their maximum size.
|
||||
/// </summary>
|
||||
API_FIELD() static Real MaxSizeDistance;
|
||||
|
||||
/// <summary>
|
||||
/// Draws the icons for the actors in the given scene (or actor tree).
|
||||
/// </summary>
|
||||
|
||||
@@ -1292,6 +1292,11 @@ namespace FlaxEditor.Viewport
|
||||
_mouseSensitivity = options.Viewport.MouseSensitivity;
|
||||
_maxSpeedSteps = options.Viewport.TotalCameraSpeedSteps;
|
||||
_cameraEasingDegree = options.Viewport.CameraEasingDegree;
|
||||
|
||||
ViewportIconsRenderer.MinSize = options.Viewport.IconsMinimumSize;
|
||||
ViewportIconsRenderer.MaxSize = options.Viewport.IconsMaximumSize;
|
||||
ViewportIconsRenderer.MaxSizeDistance = options.Viewport.MaxSizeDistance;
|
||||
|
||||
OnCameraMovementProgressChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ using System.Linq;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.Gizmo;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.GUI.Input;
|
||||
using FlaxEditor.Modules;
|
||||
using FlaxEditor.SceneGraph;
|
||||
using FlaxEditor.Scripting;
|
||||
using FlaxEditor.Viewport.Cameras;
|
||||
@@ -13,6 +15,7 @@ using FlaxEditor.Viewport.Previews;
|
||||
using FlaxEditor.Windows.Assets;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using FlaxEngine.Json;
|
||||
using Utils = FlaxEditor.Utilities.Utils;
|
||||
|
||||
namespace FlaxEditor.Viewport
|
||||
@@ -70,8 +73,11 @@ namespace FlaxEditor.Viewport
|
||||
|
||||
private PrefabUIEditorRoot _uiRoot;
|
||||
private bool _showUI = false;
|
||||
|
||||
|
||||
private int _defaultScaleActiveIndex = 0;
|
||||
private int _customScaleActiveIndex = -1;
|
||||
private ContextMenuButton _uiModeButton;
|
||||
private ContextMenuChildMenu _uiViewOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the UI Mode is toggled.
|
||||
@@ -137,6 +143,8 @@ namespace FlaxEditor.Viewport
|
||||
UseAutomaticTaskManagement = defaultFeatures;
|
||||
ShowDefaultSceneActors = defaultFeatures;
|
||||
TintColor = defaultFeatures ? Color.White : Color.Transparent;
|
||||
if (_uiViewOptions != null)
|
||||
_uiViewOptions.Visible = _showUI;
|
||||
UIModeToggled?.Invoke(_showUI);
|
||||
}
|
||||
}
|
||||
@@ -210,7 +218,7 @@ namespace FlaxEditor.Viewport
|
||||
_uiParentLink = _uiRoot.UIRoot;
|
||||
|
||||
// UI mode buton
|
||||
_uiModeButton = ViewWidgetShowMenu.AddButton("UI Mode", (button) => ShowUI = button.Checked);
|
||||
_uiModeButton = ViewWidgetShowMenu.AddButton("UI Mode", button => ShowUI = button.Checked);
|
||||
_uiModeButton.AutoCheck = true;
|
||||
_uiModeButton.VisibleChanged += control => (control as ContextMenuButton).Checked = ShowUI;
|
||||
|
||||
@@ -222,6 +230,84 @@ namespace FlaxEditor.Viewport
|
||||
SetUpdate(ref _update, OnUpdate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the view scaling options. Needs to be called after a Prefab is valid and loaded.
|
||||
/// </summary>
|
||||
public void CreateViewScalingOptions()
|
||||
{
|
||||
if (_uiViewOptions != null)
|
||||
return;
|
||||
_uiViewOptions = ViewWidgetButtonMenu.AddChildMenu("UI View Scaling");
|
||||
_uiViewOptions.Visible = _showUI;
|
||||
LoadCustomUIScalingOption();
|
||||
Editor.Instance.UI.CreateViewportSizingContextMenu(_uiViewOptions.ContextMenu, _defaultScaleActiveIndex, _customScaleActiveIndex, true, ChangeUIView, (a, b) =>
|
||||
{
|
||||
_defaultScaleActiveIndex = a;
|
||||
_customScaleActiveIndex = b;
|
||||
});
|
||||
}
|
||||
|
||||
private void ChangeUIView(UIModule.ViewportScaleOption uiViewScaleOption)
|
||||
{
|
||||
_uiRoot.SetViewSize((Float2)uiViewScaleOption.Size);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the active ui scaling option.
|
||||
/// </summary>
|
||||
public void SaveActiveUIScalingOption()
|
||||
{
|
||||
var defaultKey = $"{Prefab.ID}:DefaultViewportScalingIndex";
|
||||
Editor.Instance.ProjectCache.SetCustomData(defaultKey, _defaultScaleActiveIndex.ToString());
|
||||
var customKey = $"{Prefab.ID}:CustomViewportScalingIndex";
|
||||
Editor.Instance.ProjectCache.SetCustomData(customKey, _customScaleActiveIndex.ToString());
|
||||
}
|
||||
|
||||
private void LoadCustomUIScalingOption()
|
||||
{
|
||||
Prefab.WaitForLoaded();
|
||||
var defaultKey = $"{Prefab.ID}:DefaultViewportScalingIndex";
|
||||
if (Editor.Instance.ProjectCache.TryGetCustomData(defaultKey, out string defaultData))
|
||||
{
|
||||
if (int.TryParse(defaultData, out var index))
|
||||
{
|
||||
var options = Editor.Instance.UI.DefaultViewportScaleOptions;
|
||||
if (options.Count > index)
|
||||
{
|
||||
_defaultScaleActiveIndex = index;
|
||||
if (index != -1)
|
||||
ChangeUIView(Editor.Instance.UI.DefaultViewportScaleOptions[index]);
|
||||
}
|
||||
// Assume option does not exist anymore so move to default.
|
||||
else if (index != -1)
|
||||
{
|
||||
_defaultScaleActiveIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var customKey = $"{Prefab.ID}:CustomViewportScalingIndex";
|
||||
if (Editor.Instance.ProjectCache.TryGetCustomData(customKey, out string data))
|
||||
{
|
||||
if (int.TryParse(data, out var index))
|
||||
{
|
||||
var options = Editor.Instance.UI.CustomViewportScaleOptions;
|
||||
if (options.Count > index)
|
||||
{
|
||||
_customScaleActiveIndex = index;
|
||||
if (index != -1)
|
||||
ChangeUIView(options[index]);
|
||||
}
|
||||
// Assume option does not exist anymore so move to default.
|
||||
else if (index != -1)
|
||||
{
|
||||
_defaultScaleActiveIndex = 0;
|
||||
_customScaleActiveIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnUpdate(float deltaTime)
|
||||
{
|
||||
for (int i = 0; i < Gizmos.Count; i++)
|
||||
|
||||
@@ -112,8 +112,9 @@ namespace FlaxEditor.Viewport.Previews
|
||||
LinkCanvas(_instance);
|
||||
|
||||
// Link UI control to the preview
|
||||
var uiControl = _instance as UIControl;
|
||||
if (_uiControlLinked == null &&
|
||||
_instance is UIControl uiControl &&
|
||||
uiControl != null &&
|
||||
uiControl.Control != null &&
|
||||
uiControl.Control.Parent == null)
|
||||
{
|
||||
@@ -128,6 +129,12 @@ namespace FlaxEditor.Viewport.Previews
|
||||
_uiControlLinked.Control.Parent = _uiParentLink;
|
||||
_hasUILinked = true;
|
||||
}
|
||||
|
||||
// Use UI mode when root is empty UI Control
|
||||
if (_uiControlLinked == null && uiControl != null && uiControl.Control == null)
|
||||
{
|
||||
_hasUILinked = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void LinkCanvas(Actor actor)
|
||||
|
||||
@@ -371,6 +371,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
else
|
||||
_viewport.SetInitialUIMode(_viewport._hasUILinked);
|
||||
_viewport.UIModeToggled += OnUIModeToggled;
|
||||
_viewport.CreateViewScalingOptions();
|
||||
Graph.MainActor = _viewport.Instance;
|
||||
Selection.Clear();
|
||||
Select(Graph.Main);
|
||||
@@ -567,6 +568,15 @@ namespace FlaxEditor.Windows.Assets
|
||||
Graph.Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnClose()
|
||||
{
|
||||
// Save current UI view size state.
|
||||
_viewport.SaveActiveUIScalingOption();
|
||||
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public EditorViewport PresenterViewport => _viewport;
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace FlaxEditor.Windows
|
||||
|
||||
var root = _root;
|
||||
root.LockChildrenRecursive();
|
||||
PerformLayout();
|
||||
|
||||
// Update tree
|
||||
var query = _foldersSearchBox.Text;
|
||||
|
||||
@@ -1085,6 +1085,8 @@ namespace FlaxEditor.Windows
|
||||
if (Editor.ContentDatabase.Find(_lastViewedFolderBeforeReload) is ContentFolder folder)
|
||||
_tree.Select(folder.Node);
|
||||
}
|
||||
|
||||
OnFoldersSearchBoxTextChanged();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
|
||||
@@ -6,6 +6,7 @@ using System.Xml;
|
||||
using FlaxEditor.Gizmo;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.GUI.Input;
|
||||
using FlaxEditor.Modules;
|
||||
using FlaxEditor.Options;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
@@ -34,8 +35,8 @@ namespace FlaxEditor.Windows
|
||||
private CursorLockMode _cursorLockMode = CursorLockMode.None;
|
||||
|
||||
// Viewport scaling variables
|
||||
private List<ViewportScaleOptions> _defaultViewportScaling = new List<ViewportScaleOptions>();
|
||||
private List<ViewportScaleOptions> _customViewportScaling = new List<ViewportScaleOptions>();
|
||||
private int _defaultScaleActiveIndex = 0;
|
||||
private int _customScaleActiveIndex = -1;
|
||||
private float _viewportAspectRatio = 1;
|
||||
private float _windowAspectRatio = 1;
|
||||
private bool _useAspect = false;
|
||||
@@ -246,35 +247,6 @@ namespace FlaxEditor.Windows
|
||||
/// </summary>
|
||||
public InterfaceOptions.PlayModeFocus FocusOnPlayOption { get; set; }
|
||||
|
||||
private enum ViewportScaleType
|
||||
{
|
||||
Resolution = 0,
|
||||
Aspect = 1,
|
||||
}
|
||||
|
||||
private class ViewportScaleOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The name.
|
||||
/// </summary>
|
||||
public string Label;
|
||||
|
||||
/// <summary>
|
||||
/// The Type of scaling to do.
|
||||
/// </summary>
|
||||
public ViewportScaleType ScaleType;
|
||||
|
||||
/// <summary>
|
||||
/// The width and height to scale by.
|
||||
/// </summary>
|
||||
public Int2 Size;
|
||||
|
||||
/// <summary>
|
||||
/// If the scaling is active.
|
||||
/// </summary>
|
||||
public bool Active;
|
||||
}
|
||||
|
||||
private class PlayModeFocusOptions
|
||||
{
|
||||
/// <summary>
|
||||
@@ -420,7 +392,7 @@ namespace FlaxEditor.Windows
|
||||
InputActions.Add(options => options.FocusConsoleCommand, () => Editor.Instance.Windows.OutputLogWin.FocusCommand());
|
||||
}
|
||||
|
||||
private void ChangeViewportRatio(ViewportScaleOptions v)
|
||||
private void ChangeViewportRatio(UIModule.ViewportScaleOption v)
|
||||
{
|
||||
if (v == null)
|
||||
return;
|
||||
@@ -439,11 +411,11 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
switch (v.ScaleType)
|
||||
{
|
||||
case ViewportScaleType.Aspect:
|
||||
case UIModule.ViewportScaleOption.ViewportScaleType.Aspect:
|
||||
_useAspect = true;
|
||||
_freeAspect = false;
|
||||
break;
|
||||
case ViewportScaleType.Resolution:
|
||||
case UIModule.ViewportScaleOption.ViewportScaleType.Resolution:
|
||||
_useAspect = false;
|
||||
_freeAspect = false;
|
||||
break;
|
||||
@@ -634,49 +606,12 @@ namespace FlaxEditor.Windows
|
||||
|
||||
// Viewport aspect ratio
|
||||
{
|
||||
// Create default scaling options if they dont exist from deserialization.
|
||||
if (_defaultViewportScaling.Count == 0)
|
||||
{
|
||||
_defaultViewportScaling.Add(new ViewportScaleOptions
|
||||
{
|
||||
Label = "Free Aspect",
|
||||
ScaleType = ViewportScaleType.Aspect,
|
||||
Size = new Int2(1, 1),
|
||||
Active = true,
|
||||
});
|
||||
_defaultViewportScaling.Add(new ViewportScaleOptions
|
||||
{
|
||||
Label = "16:9 Aspect",
|
||||
ScaleType = ViewportScaleType.Aspect,
|
||||
Size = new Int2(16, 9),
|
||||
Active = false,
|
||||
});
|
||||
_defaultViewportScaling.Add(new ViewportScaleOptions
|
||||
{
|
||||
Label = "16:10 Aspect",
|
||||
ScaleType = ViewportScaleType.Aspect,
|
||||
Size = new Int2(16, 10),
|
||||
Active = false,
|
||||
});
|
||||
_defaultViewportScaling.Add(new ViewportScaleOptions
|
||||
{
|
||||
Label = "1920x1080 Resolution (Full HD)",
|
||||
ScaleType = ViewportScaleType.Resolution,
|
||||
Size = new Int2(1920, 1080),
|
||||
Active = false,
|
||||
});
|
||||
_defaultViewportScaling.Add(new ViewportScaleOptions
|
||||
{
|
||||
Label = "2560x1440 Resolution (2K)",
|
||||
ScaleType = ViewportScaleType.Resolution,
|
||||
Size = new Int2(2560, 1440),
|
||||
Active = false,
|
||||
});
|
||||
}
|
||||
|
||||
var vsMenu = menu.AddChildMenu("Viewport Size").ContextMenu;
|
||||
|
||||
CreateViewportSizingContextMenu(vsMenu);
|
||||
Editor.UI.CreateViewportSizingContextMenu(vsMenu, _defaultScaleActiveIndex, _customScaleActiveIndex, false, ChangeViewportRatio, (a, b) =>
|
||||
{
|
||||
_defaultScaleActiveIndex = a;
|
||||
_customScaleActiveIndex = b;
|
||||
});
|
||||
}
|
||||
|
||||
// Take Screenshot
|
||||
@@ -774,243 +709,6 @@ namespace FlaxEditor.Windows
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateViewportSizingContextMenu(ContextMenu vsMenu)
|
||||
{
|
||||
// Add default viewport sizing options
|
||||
for (int i = 0; i < _defaultViewportScaling.Count; i++)
|
||||
{
|
||||
var viewportScale = _defaultViewportScaling[i];
|
||||
var button = vsMenu.AddButton(viewportScale.Label);
|
||||
button.CloseMenuOnClick = false;
|
||||
button.Icon = viewportScale.Active ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
|
||||
button.Tag = viewportScale;
|
||||
if (viewportScale.Active)
|
||||
ChangeViewportRatio(viewportScale);
|
||||
|
||||
button.Clicked += () =>
|
||||
{
|
||||
if (button.Tag == null)
|
||||
return;
|
||||
|
||||
// Reset selected icon on all buttons
|
||||
foreach (var child in vsMenu.Items)
|
||||
{
|
||||
if (child is ContextMenuButton cmb && cmb.Tag is ViewportScaleOptions v)
|
||||
{
|
||||
if (cmb == button)
|
||||
{
|
||||
v.Active = true;
|
||||
button.Icon = Style.Current.CheckBoxTick;
|
||||
ChangeViewportRatio(v);
|
||||
}
|
||||
else if (v.Active)
|
||||
{
|
||||
cmb.Icon = SpriteHandle.Invalid;
|
||||
v.Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
if (_defaultViewportScaling.Count != 0)
|
||||
vsMenu.AddSeparator();
|
||||
|
||||
// Add custom viewport options
|
||||
for (int i = 0; i < _customViewportScaling.Count; i++)
|
||||
{
|
||||
var viewportScale = _customViewportScaling[i];
|
||||
var childCM = vsMenu.AddChildMenu(viewportScale.Label);
|
||||
childCM.CloseMenuOnClick = false;
|
||||
childCM.Icon = viewportScale.Active ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
|
||||
childCM.Tag = viewportScale;
|
||||
if (viewportScale.Active)
|
||||
ChangeViewportRatio(viewportScale);
|
||||
|
||||
var applyButton = childCM.ContextMenu.AddButton("Apply");
|
||||
applyButton.Tag = childCM.Tag = viewportScale;
|
||||
applyButton.CloseMenuOnClick = false;
|
||||
applyButton.Clicked += () =>
|
||||
{
|
||||
if (childCM.Tag == null)
|
||||
return;
|
||||
|
||||
// Reset selected icon on all buttons
|
||||
foreach (var child in vsMenu.Items)
|
||||
{
|
||||
if (child is ContextMenuButton cmb && cmb.Tag is ViewportScaleOptions v)
|
||||
{
|
||||
if (child == childCM)
|
||||
{
|
||||
v.Active = true;
|
||||
childCM.Icon = Style.Current.CheckBoxTick;
|
||||
ChangeViewportRatio(v);
|
||||
}
|
||||
else if (v.Active)
|
||||
{
|
||||
cmb.Icon = SpriteHandle.Invalid;
|
||||
v.Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var deleteButton = childCM.ContextMenu.AddButton("Delete");
|
||||
deleteButton.CloseMenuOnClick = false;
|
||||
deleteButton.Clicked += () =>
|
||||
{
|
||||
if (childCM.Tag == null)
|
||||
return;
|
||||
|
||||
var v = (ViewportScaleOptions)childCM.Tag;
|
||||
if (v.Active)
|
||||
{
|
||||
v.Active = false;
|
||||
_defaultViewportScaling[0].Active = true;
|
||||
ChangeViewportRatio(_defaultViewportScaling[0]);
|
||||
}
|
||||
_customViewportScaling.Remove(v);
|
||||
vsMenu.DisposeAllItems();
|
||||
CreateViewportSizingContextMenu(vsMenu);
|
||||
vsMenu.PerformLayout();
|
||||
};
|
||||
}
|
||||
if (_customViewportScaling.Count != 0)
|
||||
vsMenu.AddSeparator();
|
||||
|
||||
// Add button
|
||||
var add = vsMenu.AddButton("Add...");
|
||||
add.CloseMenuOnClick = false;
|
||||
add.Clicked += () =>
|
||||
{
|
||||
var popup = new ContextMenuBase
|
||||
{
|
||||
Size = new Float2(230, 125),
|
||||
ClipChildren = false,
|
||||
CullChildren = false,
|
||||
};
|
||||
popup.Show(add, new Float2(add.Width, 0));
|
||||
|
||||
var nameLabel = new Label
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Name",
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
};
|
||||
nameLabel.LocalX += 10;
|
||||
nameLabel.LocalY += 10;
|
||||
|
||||
var nameTextBox = new TextBox
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
IsMultiline = false,
|
||||
};
|
||||
nameTextBox.LocalX += 100;
|
||||
nameTextBox.LocalY += 10;
|
||||
|
||||
var typeLabel = new Label
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Type",
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
};
|
||||
typeLabel.LocalX += 10;
|
||||
typeLabel.LocalY += 35;
|
||||
|
||||
var typeDropdown = new Dropdown
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Items = { "Aspect", "Resolution" },
|
||||
SelectedItem = "Aspect",
|
||||
Width = nameTextBox.Width
|
||||
};
|
||||
typeDropdown.LocalY += 35;
|
||||
typeDropdown.LocalX += 100;
|
||||
|
||||
var whLabel = new Label
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Width & Height",
|
||||
HorizontalAlignment = TextAlignment.Near,
|
||||
};
|
||||
whLabel.LocalX += 10;
|
||||
whLabel.LocalY += 60;
|
||||
|
||||
var wValue = new IntValueBox(16)
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
MinValue = 1,
|
||||
Width = 55,
|
||||
};
|
||||
wValue.LocalY += 60;
|
||||
wValue.LocalX += 100;
|
||||
|
||||
var hValue = new IntValueBox(9)
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
MinValue = 1,
|
||||
Width = 55,
|
||||
};
|
||||
hValue.LocalY += 60;
|
||||
hValue.LocalX += 165;
|
||||
|
||||
var submitButton = new Button
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Submit",
|
||||
Width = 70,
|
||||
};
|
||||
submitButton.LocalX += 40;
|
||||
submitButton.LocalY += 90;
|
||||
|
||||
submitButton.Clicked += () =>
|
||||
{
|
||||
Enum.TryParse(typeDropdown.SelectedItem, out ViewportScaleType type);
|
||||
|
||||
var combineString = type == ViewportScaleType.Aspect ? ":" : "x";
|
||||
var name = nameTextBox.Text + " (" + wValue.Value + combineString + hValue.Value + ") " + typeDropdown.SelectedItem;
|
||||
|
||||
var newViewportOption = new ViewportScaleOptions
|
||||
{
|
||||
ScaleType = type,
|
||||
Label = name,
|
||||
Size = new Int2(wValue.Value, hValue.Value),
|
||||
};
|
||||
|
||||
_customViewportScaling.Add(newViewportOption);
|
||||
vsMenu.DisposeAllItems();
|
||||
CreateViewportSizingContextMenu(vsMenu);
|
||||
vsMenu.PerformLayout();
|
||||
};
|
||||
|
||||
var cancelButton = new Button
|
||||
{
|
||||
Parent = popup,
|
||||
AnchorPreset = AnchorPresets.TopLeft,
|
||||
Text = "Cancel",
|
||||
Width = 70,
|
||||
};
|
||||
cancelButton.LocalX += 120;
|
||||
cancelButton.LocalY += 90;
|
||||
|
||||
cancelButton.Clicked += () =>
|
||||
{
|
||||
nameTextBox.Clear();
|
||||
typeDropdown.SelectedItem = "Aspect";
|
||||
hValue.Value = 9;
|
||||
wValue.Value = 16;
|
||||
popup.Hide();
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Draw()
|
||||
{
|
||||
@@ -1233,8 +931,8 @@ namespace FlaxEditor.Windows
|
||||
writer.WriteAttributeString("ShowGUI", ShowGUI.ToString());
|
||||
writer.WriteAttributeString("EditGUI", EditGUI.ToString());
|
||||
writer.WriteAttributeString("ShowDebugDraw", ShowDebugDraw.ToString());
|
||||
writer.WriteAttributeString("DefaultViewportScaling", JsonSerializer.Serialize(_defaultViewportScaling));
|
||||
writer.WriteAttributeString("CustomViewportScaling", JsonSerializer.Serialize(_customViewportScaling));
|
||||
writer.WriteAttributeString("DefaultViewportScalingIndex", _defaultScaleActiveIndex.ToString());
|
||||
writer.WriteAttributeString("CustomViewportScalingIndex", _customScaleActiveIndex.ToString());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1246,22 +944,30 @@ namespace FlaxEditor.Windows
|
||||
EditGUI = value1;
|
||||
if (bool.TryParse(node.GetAttribute("ShowDebugDraw"), out value1))
|
||||
ShowDebugDraw = value1;
|
||||
if (node.HasAttribute("CustomViewportScaling"))
|
||||
_customViewportScaling = JsonSerializer.Deserialize<List<ViewportScaleOptions>>(node.GetAttribute("CustomViewportScaling"));
|
||||
if (int.TryParse(node.GetAttribute("DefaultViewportScalingIndex"), out int value2))
|
||||
_defaultScaleActiveIndex = value2;
|
||||
if (int.TryParse(node.GetAttribute("CustomViewportScalingIndex"), out value2))
|
||||
_customScaleActiveIndex = value2;
|
||||
|
||||
for (int i = 0; i < _customViewportScaling.Count; i++)
|
||||
if (_defaultScaleActiveIndex != -1)
|
||||
{
|
||||
if (_customViewportScaling[i].Active)
|
||||
ChangeViewportRatio(_customViewportScaling[i]);
|
||||
var options = Editor.UI.DefaultViewportScaleOptions;
|
||||
if (options.Count > _defaultScaleActiveIndex)
|
||||
ChangeViewportRatio(options[_defaultScaleActiveIndex]);
|
||||
else
|
||||
_defaultScaleActiveIndex = 0;
|
||||
}
|
||||
|
||||
if (node.HasAttribute("DefaultViewportScaling"))
|
||||
_defaultViewportScaling = JsonSerializer.Deserialize<List<ViewportScaleOptions>>(node.GetAttribute("DefaultViewportScaling"));
|
||||
|
||||
for (int i = 0; i < _defaultViewportScaling.Count; i++)
|
||||
|
||||
if (_customScaleActiveIndex != -1)
|
||||
{
|
||||
if (_defaultViewportScaling[i].Active)
|
||||
ChangeViewportRatio(_defaultViewportScaling[i]);
|
||||
var options = Editor.UI.CustomViewportScaleOptions;
|
||||
if (options.Count > _customScaleActiveIndex)
|
||||
ChangeViewportRatio(options[_customScaleActiveIndex]);
|
||||
else
|
||||
{
|
||||
_defaultScaleActiveIndex = 0;
|
||||
_customScaleActiveIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ namespace FlaxEditor.Windows
|
||||
});
|
||||
var flags = DebugCommands.GetCommandFlags(command);
|
||||
if (flags.HasFlag(DebugCommands.CommandFlags.Exec))
|
||||
lastItem.TintColor = new Color(0.85f, 0.85f, 1.0f, 1.0f);
|
||||
lastItem.TintColor = new Color(0.75f, 0.75f, 1.0f, 1.0f);
|
||||
else if (flags.HasFlag(DebugCommands.CommandFlags.Read) && !flags.HasFlag(DebugCommands.CommandFlags.Write))
|
||||
lastItem.TintColor = new Color(0.85f, 0.85f, 0.85f, 1.0f);
|
||||
lastItem.Focused += item =>
|
||||
@@ -320,12 +320,25 @@ namespace FlaxEditor.Windows
|
||||
|
||||
// Show commands search popup based on current text input
|
||||
var text = Text.Trim();
|
||||
if (text.Length != 0)
|
||||
bool isWhitespaceOnly = string.IsNullOrWhiteSpace(Text) && !string.IsNullOrEmpty(Text);
|
||||
if (text.Length != 0 || isWhitespaceOnly)
|
||||
{
|
||||
DebugCommands.Search(text, out var matches);
|
||||
if (matches.Length != 0)
|
||||
if (matches.Length != 0 || isWhitespaceOnly)
|
||||
{
|
||||
ShowPopup(ref _searchPopup, matches, text);
|
||||
string[] commands = [];
|
||||
if (isWhitespaceOnly)
|
||||
DebugCommands.GetAllCommands(out commands);
|
||||
|
||||
ShowPopup(ref _searchPopup, isWhitespaceOnly ? commands : matches, text);
|
||||
|
||||
if (isWhitespaceOnly)
|
||||
{
|
||||
// Scroll to and select first item for consistent behaviour
|
||||
var firstItem = _searchPopup.ItemsPanel.Children[0] as Item;
|
||||
_searchPopup.ScrollToAndHighlightItemByName(firstItem.Name);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ namespace FlaxEditor.Windows
|
||||
TooltipText = "Search the scene tree.\n\nYou can prefix your search with different search operators:\ns: -> Actor with script of type\na: -> Actor type\nc: -> Control type",
|
||||
};
|
||||
_searchBox.TextChanged += OnSearchBoxTextChanged;
|
||||
ScriptsBuilder.ScriptsReloadEnd += OnSearchBoxTextChanged;
|
||||
|
||||
// Scene tree panel
|
||||
_sceneTreePanel = new Panel
|
||||
@@ -112,7 +113,7 @@ namespace FlaxEditor.Windows
|
||||
InputActions.Add(options => options.LockFocusSelection, () => Editor.Windows.EditWin.Viewport.LockFocusSelection());
|
||||
InputActions.Add(options => options.Rename, RenameSelection);
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void OnPlayBeginning()
|
||||
{
|
||||
@@ -125,6 +126,7 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
base.OnPlayBegin();
|
||||
_blockSceneTreeScroll = false;
|
||||
OnSearchBoxTextChanged();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -139,6 +141,7 @@ namespace FlaxEditor.Windows
|
||||
{
|
||||
base.OnPlayEnd();
|
||||
_blockSceneTreeScroll = true;
|
||||
OnSearchBoxTextChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,6 +177,7 @@ namespace FlaxEditor.Windows
|
||||
return;
|
||||
|
||||
_tree.LockChildrenRecursive();
|
||||
PerformLayout();
|
||||
|
||||
// Update tree
|
||||
var query = _searchBox.Text;
|
||||
@@ -599,6 +603,7 @@ namespace FlaxEditor.Windows
|
||||
_dragHandlers = null;
|
||||
_tree = null;
|
||||
_searchBox = null;
|
||||
ScriptsBuilder.ScriptsReloadEnd -= OnSearchBoxTextChanged;
|
||||
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ void AudioSource::Play()
|
||||
}
|
||||
else
|
||||
{
|
||||
// Source was nt properly added to the Audio Backend
|
||||
LOG(Warning, "Cannot play unitialized audio source.");
|
||||
// Source was not properly added to the Audio Backend
|
||||
LOG(Warning, "Cannot play uninitialized audio source.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,6 +408,9 @@ void AudioSource::Update()
|
||||
_startingToPlay = false;
|
||||
}
|
||||
|
||||
if (Math::NearEqual(GetTime(), _startTime) && _isActuallyPlayingSth && _startingToPlay)
|
||||
ClipStarted();
|
||||
|
||||
if (!UseStreaming() && Math::NearEqual(GetTime(), 0.0f) && _isActuallyPlayingSth && !_startingToPlay)
|
||||
{
|
||||
int32 queuedBuffers;
|
||||
@@ -423,6 +426,7 @@ void AudioSource::Update()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
ClipFinished();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -493,6 +497,7 @@ void AudioSource::Update()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
ClipFinished();
|
||||
}
|
||||
ASSERT(_streamingFirstChunk < clip->Buffers.Count());
|
||||
|
||||
|
||||
@@ -76,6 +76,16 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(10), DefaultValue(null), EditorDisplay(\"Audio Source\")")
|
||||
AssetReference<AudioClip> Clip;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the audio clip starts.
|
||||
/// </summary>
|
||||
API_EVENT() Action ClipStarted;
|
||||
|
||||
/// <summary>
|
||||
/// Event fired when the audio clip finishes.
|
||||
/// </summary>
|
||||
API_EVENT() Action ClipFinished;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the velocity of the source. Determines pitch in relation to AudioListener's position. Only relevant for spatial (3D) sources.
|
||||
/// </summary>
|
||||
|
||||
@@ -90,9 +90,11 @@ void MaterialInstance::OnBaseParamsChanged()
|
||||
// Get the newest parameters
|
||||
baseParams->Clone(Params);
|
||||
|
||||
#if 0
|
||||
// Override all public parameters by default
|
||||
for (auto& param : Params)
|
||||
param.SetIsOverride(param.IsPublic());
|
||||
#endif
|
||||
|
||||
// Copy previous parameters values
|
||||
for (int32 i = 0; i < oldParams.Count(); i++)
|
||||
|
||||
@@ -93,14 +93,15 @@ namespace
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void AddInput(MaterialLayer* layer, Meta11 meta, MaterialGraphBoxes box, const Guid& texture, const T& value, const T& defaultValue, const Float2& pos, ShaderGraphNode<>** outTextureNode = nullptr)
|
||||
void AddInput(MaterialLayer* layer, Meta11 meta, MaterialGraphBoxes box, const Guid& texture, const T& value, const T& defaultValue, const Float2& pos, ShaderGraphNode<>** outTextureNode = nullptr, uint8 channel = MAX_uint8)
|
||||
{
|
||||
auto textureNode = AddTextureNode(layer, texture);
|
||||
auto valueNode = AddValueNode<T>(layer, value, defaultValue);
|
||||
auto textureNodeBox = channel == MAX_uint8 ? 1 : channel + 2; // Color or specific channel (RGBA)
|
||||
if (textureNode && valueNode)
|
||||
{
|
||||
auto diffuseMultiply = AddMultiplyNode(layer);
|
||||
CONNECT(diffuseMultiply->Boxes[0], textureNode->Boxes[1]);
|
||||
CONNECT(diffuseMultiply->Boxes[0], textureNode->Boxes[textureNodeBox]);
|
||||
CONNECT(diffuseMultiply->Boxes[1], valueNode->Boxes[0]);
|
||||
CONNECT(layer->Root->Boxes[static_cast<int32>(box)], diffuseMultiply->Boxes[2]);
|
||||
SET_POS(valueNode, pos + Float2(-467.7404, 91.41332));
|
||||
@@ -109,7 +110,7 @@ namespace
|
||||
}
|
||||
else if (textureNode)
|
||||
{
|
||||
CONNECT(layer->Root->Boxes[static_cast<int32>(box)], textureNode->Boxes[1]);
|
||||
CONNECT(layer->Root->Boxes[static_cast<int32>(box)], textureNode->Boxes[textureNodeBox]);
|
||||
SET_POS(textureNode, pos + Float2(-293.5272f, -2.926111f));
|
||||
}
|
||||
else if (valueNode)
|
||||
@@ -178,8 +179,9 @@ CreateAssetResult CreateMaterial::Create(CreateAssetContext& context)
|
||||
// Opacity
|
||||
AddInput(layer, meta, MaterialGraphBoxes::Opacity, options.Opacity.Texture, options.Opacity.Value, 1.0f, Float2(0, 400));
|
||||
|
||||
// Opacity
|
||||
AddInput(layer, meta, MaterialGraphBoxes::Roughness, options.Roughness.Texture, options.Roughness.Value, 0.5f, Float2(200, 400));
|
||||
// Roughness + Metalness
|
||||
AddInput(layer, meta, MaterialGraphBoxes::Roughness, options.Roughness.Texture, options.Roughness.Value, 0.5f, Float2(200, 400), nullptr, options.Roughness.Channel);
|
||||
AddInput(layer, meta, MaterialGraphBoxes::Metalness, options.Metalness.Texture, options.Metalness.Value, 0.0f, Float2(200, 600), nullptr, options.Metalness.Channel);
|
||||
|
||||
// Normal
|
||||
auto normalMap = AddTextureNode(layer, options.Normals.Texture, true);
|
||||
|
||||
@@ -40,9 +40,17 @@ public:
|
||||
struct
|
||||
{
|
||||
float Value = 0.5f;
|
||||
uint8 Channel = 0;
|
||||
Guid Texture = Guid::Empty;
|
||||
} Roughness;
|
||||
|
||||
struct
|
||||
{
|
||||
float Value = 0.0f;
|
||||
uint8 Channel = 0;
|
||||
Guid Texture = Guid::Empty;
|
||||
} Metalness;
|
||||
|
||||
struct
|
||||
{
|
||||
Guid Texture = Guid::Empty;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "Engine/Utilities/RectPack.h"
|
||||
#include "Engine/Scripting/Scripting.h"
|
||||
#include "Engine/Profiler/ProfilerCPU.h"
|
||||
#include "Editor/Utilities/EditorUtilities.h"
|
||||
#include "AssetsImportingManager.h"
|
||||
|
||||
bool ImportModel::TryGetImportOptions(const StringView& path, Options& options)
|
||||
@@ -281,13 +282,19 @@ CreateAssetResult ImportModel::Import(CreateAssetContext& context)
|
||||
|
||||
// Import all of the objects recursive but use current model data to skip loading file again
|
||||
options.Cached = &cached;
|
||||
Function<bool(Options& splitOptions, const StringView& objectName, String& outputPath, MeshData* meshData)> splitImport = [&context, &autoImportOutput](Options& splitOptions, const StringView& objectName, String& outputPath, MeshData* meshData)
|
||||
HashSet<String> objectNames;
|
||||
Function<bool(Options& splitOptions, const StringView& objectName, String& outputPath, MeshData* meshData)> splitImport = [&context, &autoImportOutput, &objectNames](Options& splitOptions, const StringView& objectName, String& outputPath, MeshData* meshData)
|
||||
{
|
||||
// Recursive importing of the split object
|
||||
String postFix = objectName;
|
||||
const int32 splitPos = postFix.FindLast(TEXT('|'));
|
||||
if (splitPos != -1)
|
||||
if (splitPos != -1 && splitPos + 1 < postFix.Length())
|
||||
postFix = postFix.Substring(splitPos + 1);
|
||||
EditorUtilities::ValidatePathChars(postFix); // Ensure name is valid path
|
||||
int32 duplicate = 0;
|
||||
String postFixPre = postFix;
|
||||
while (!objectNames.Add(postFix)) // Ensure name is unique
|
||||
postFix = String::Format(TEXT("{} {}"), postFixPre, duplicate++);
|
||||
// TODO: check for name collisions with material/texture assets
|
||||
outputPath = autoImportOutput / String(StringUtils::GetFileNameWithoutExtension(context.TargetAssetPath)) + TEXT(" ") + postFix + TEXT(".flax");
|
||||
splitOptions.SubAssetFolder = TEXT(" "); // Use the same folder as asset as they all are imported to the subdir for the prefab (see SubAssetFolder usage above)
|
||||
|
||||
@@ -460,6 +460,14 @@ void DebugCommands::InitAsync()
|
||||
AsyncTask = Task::StartNew(InitCommands);
|
||||
}
|
||||
|
||||
void DebugCommands::GetAllCommands(Array<StringView>& commands)
|
||||
{
|
||||
EnsureInited();
|
||||
ScopeLock lock(Locker);
|
||||
for (const auto& command : Commands)
|
||||
commands.Add(command.Name);
|
||||
}
|
||||
|
||||
DebugCommands::CommandFlags DebugCommands::GetCommandFlags(StringView command)
|
||||
{
|
||||
CommandFlags result = CommandFlags::None;
|
||||
|
||||
@@ -46,6 +46,12 @@ public:
|
||||
/// </summary>
|
||||
API_FUNCTION() static void InitAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Gets all available commands.
|
||||
/// </summary>
|
||||
/// <param name="commands">The output list of all commands (unsorted).</param>
|
||||
API_FUNCTION() static void GetAllCommands(API_PARAM(Out) Array<StringView, HeapAllocation>& commands);
|
||||
|
||||
/// <summary>
|
||||
/// Returns flags of the command.
|
||||
/// </summary>
|
||||
|
||||
@@ -156,8 +156,8 @@ public:
|
||||
/// </summary>
|
||||
GPUTextureView* Input = nullptr;
|
||||
|
||||
BindParameters(::GPUContext* context, const ::RenderContext& renderContext);
|
||||
BindParameters(::GPUContext* context, const ::RenderContext& renderContext, const ::DrawCall& drawCall, bool instanced = false);
|
||||
FLAXENGINE_API BindParameters(::GPUContext* context, const ::RenderContext& renderContext);
|
||||
FLAXENGINE_API BindParameters(::GPUContext* context, const ::RenderContext& renderContext, const ::DrawCall& drawCall, bool instanced = false);
|
||||
|
||||
// Per-view shared constant buffer (see ViewData in MaterialCommon.hlsl).
|
||||
static GPUConstantBuffer* PerViewConstants;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "MaterialShaderFeatures.h"
|
||||
#include "Engine/Graphics/RenderTask.h"
|
||||
#include "Engine/Graphics/RenderBuffers.h"
|
||||
#include "Engine/Graphics/Textures/GPUTexture.h"
|
||||
#include "Engine/Renderer/RenderList.h"
|
||||
#include "Engine/Renderer/ShadowsPass.h"
|
||||
@@ -24,18 +25,27 @@ void ForwardShadingFeature::Bind(MaterialShader::BindParameters& params, Span<by
|
||||
const int32 skyLightShaderRegisterIndex = srv + 1;
|
||||
const int32 shadowsBufferRegisterIndex = srv + 2;
|
||||
const int32 shadowMapShaderRegisterIndex = srv + 3;
|
||||
const int32 volumetricFogTextureRegisterIndex = srv + 4;
|
||||
const bool canUseShadow = view.Pass != DrawPass::Depth;
|
||||
|
||||
// Set fog input
|
||||
GPUTextureView* volumetricFogTexture = nullptr;
|
||||
if (cache->Fog)
|
||||
{
|
||||
cache->Fog->GetExponentialHeightFogData(view, data.ExponentialHeightFog);
|
||||
VolumetricFogOptions volumetricFog;
|
||||
cache->Fog->GetVolumetricFogOptions(volumetricFog);
|
||||
if (volumetricFog.UseVolumetricFog() && params.RenderContext.Buffers->VolumetricFog)
|
||||
volumetricFogTexture = params.RenderContext.Buffers->VolumetricFog->ViewVolume();
|
||||
else
|
||||
data.ExponentialHeightFog.VolumetricFogMaxDistance = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
data.ExponentialHeightFog.FogMinOpacity = 1.0f;
|
||||
data.ExponentialHeightFog.ApplyDirectionalInscattering = 0.0f;
|
||||
}
|
||||
params.GPUContext->BindSR(volumetricFogTextureRegisterIndex, volumetricFogTexture);
|
||||
|
||||
// Set directional light input
|
||||
if (cache->DirectionalLights.HasItems())
|
||||
|
||||
@@ -25,7 +25,7 @@ struct ForwardShadingFeature : MaterialShaderFeature
|
||||
{
|
||||
enum { MaxLocalLights = 4 };
|
||||
|
||||
enum { SRVs = 4 };
|
||||
enum { SRVs = 5 };
|
||||
|
||||
PACK_STRUCT(struct Data
|
||||
{
|
||||
|
||||
@@ -372,6 +372,8 @@ bool MaterialSlotEntry::UsesProperties() const
|
||||
Opacity.TextureIndex != -1 ||
|
||||
Math::NotNearEqual(Roughness.Value, 0.5f) ||
|
||||
Roughness.TextureIndex != -1 ||
|
||||
Math::NotNearEqual(Metalness.Value, 0.5f) ||
|
||||
Metalness.TextureIndex != -1 ||
|
||||
Normals.TextureIndex != -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -327,14 +327,23 @@ struct FLAXENGINE_API MaterialSlotEntry
|
||||
{
|
||||
float Value = 0.5f;
|
||||
int32 TextureIndex = -1;
|
||||
uint8 Channel = 0;
|
||||
} Roughness;
|
||||
|
||||
struct
|
||||
{
|
||||
float Value = 0.0f;
|
||||
int32 TextureIndex = -1;
|
||||
uint8 Channel = 0;
|
||||
} Metalness;
|
||||
|
||||
struct
|
||||
{
|
||||
int32 TextureIndex = -1;
|
||||
} Normals;
|
||||
|
||||
bool TwoSided = false;
|
||||
bool Wireframe = false;
|
||||
|
||||
bool UsesProperties() const;
|
||||
static float ShininessToRoughness(float shininess);
|
||||
|
||||
@@ -1185,14 +1185,11 @@ void Actor::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
|
||||
}
|
||||
else if (!parent && parentId.IsValid())
|
||||
{
|
||||
Guid tmpId;
|
||||
if (_prefabObjectID.IsValid())
|
||||
{
|
||||
LOG(Warning, "Missing parent actor {0} for \'{1}\', prefab object {2}", parentId, ToString(), _prefabObjectID);
|
||||
}
|
||||
else
|
||||
{
|
||||
else if (!modifier->IdsMapping.TryGet(parentId, tmpId) || tmpId.IsValid()) // Skip warning if object was mapped to empty id (intentionally ignored)
|
||||
LOG(Warning, "Missing parent actor {0} for \'{1}\'", parentId, ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1757,7 +1754,7 @@ bool Actor::ToBytes(const Array<Actor*>& actors, MemoryWriteStream& output)
|
||||
}
|
||||
|
||||
// Collect object ids that exist in the serialized data to allow references mapping later
|
||||
Array<Guid> ids(Math::RoundUpToPowerOf2(actors.Count() * 2));
|
||||
Array<Guid> ids(actors.Count());
|
||||
for (int32 i = 0; i < actors.Count(); i++)
|
||||
{
|
||||
// By default we collect actors and scripts (they are ManagedObjects recognized by the id)
|
||||
@@ -2060,19 +2057,27 @@ Actor* Actor::Clone()
|
||||
|
||||
// Remap object ids into a new ones
|
||||
auto modifier = Cache::ISerializeModifier.Get();
|
||||
for (int32 i = 0; i < actors->Count(); i++)
|
||||
for (const Actor* actor : *actors.Value)
|
||||
{
|
||||
auto actor = actors->At(i);
|
||||
if (!actor)
|
||||
continue;
|
||||
modifier->IdsMapping.Add(actor->GetID(), Guid::New());
|
||||
for (int32 j = 0; j < actor->Scripts.Count(); j++)
|
||||
for (const Script* script : actor->Scripts)
|
||||
{
|
||||
const auto script = actor->Scripts[j];
|
||||
if (script)
|
||||
modifier->IdsMapping.Add(script->GetID(), Guid::New());
|
||||
}
|
||||
}
|
||||
if (HasPrefabLink() && HasParent() && !IsPrefabRoot())
|
||||
{
|
||||
// When cloning actor that is part of prefab (but not as whole), ignore the prefab hierarchy
|
||||
Actor* parent = GetParent();
|
||||
do
|
||||
{
|
||||
modifier->IdsMapping.Add(parent->GetPrefabObjectID(), Guid::Empty);
|
||||
parent = parent->GetParent();
|
||||
} while (parent && !parent->IsPrefabRoot());
|
||||
}
|
||||
|
||||
// Deserialize objects
|
||||
Array<Actor*> output;
|
||||
|
||||
@@ -63,7 +63,8 @@ protected:
|
||||
{
|
||||
const float dst2 = (float)Vector3::DistanceSquared(viewPosition, position);
|
||||
const float dst = Math::Sqrt(dst2);
|
||||
brightness *= Math::Remap(dst, 0.9f * ViewDistance, ViewDistance, 1.0f, 0.0f);
|
||||
if (dst < ViewDistance && dst > ViewDistance * 0.9f)
|
||||
brightness *= Math::Remap(dst, 0.9f * ViewDistance, ViewDistance, 1.0f, 0.0f);
|
||||
return dst < ViewDistance;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -129,6 +129,7 @@ void Skybox::ApplySky(GPUContext* context, RenderContext& renderContext, const M
|
||||
material->SetParameterValue(TEXT("PanoramicTexture"), PanoramicTexture.Get(), false);
|
||||
material->SetParameterValue(TEXT("Color"), Color * Math::Exp2(Exposure), false);
|
||||
material->SetParameterValue(TEXT("IsPanoramic"), PanoramicTexture != nullptr, false);
|
||||
material->SetParameterValue(TEXT("RotationEuler"), _rotationEuler, false);
|
||||
material->Bind(bindParams);
|
||||
}
|
||||
}
|
||||
@@ -163,4 +164,5 @@ void Skybox::OnTransformChanged()
|
||||
|
||||
_box = BoundingBox(_transform.Translation);
|
||||
_sphere = BoundingSphere(_transform.Translation, 0.0f);
|
||||
_rotationEuler = GetOrientation().GetEuler() * DegreesToRadians;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class FLAXENGINE_API Skybox : public Actor, public ISkyRenderer
|
||||
private:
|
||||
AssetReference<MaterialInstance> _proxyMaterial;
|
||||
int32 _sceneRenderingKey = -1;
|
||||
Float3 _rotationEuler;
|
||||
|
||||
public:
|
||||
/// <summary>
|
||||
|
||||
@@ -201,6 +201,11 @@ void WheeledVehicle::SetSteering(float value)
|
||||
_steering = Math::Clamp(value, -1.0f, 1.0f);
|
||||
}
|
||||
|
||||
float WheeledVehicle::GetSteering()
|
||||
{
|
||||
return _steering;
|
||||
}
|
||||
|
||||
void WheeledVehicle::SetBrake(float value)
|
||||
{
|
||||
value = Math::Saturate(value);
|
||||
@@ -209,11 +214,21 @@ void WheeledVehicle::SetBrake(float value)
|
||||
_tankRightBrake = value;
|
||||
}
|
||||
|
||||
float WheeledVehicle::GetBrake()
|
||||
{
|
||||
return _brake;
|
||||
}
|
||||
|
||||
void WheeledVehicle::SetHandbrake(float value)
|
||||
{
|
||||
_handBrake = Math::Saturate(value);
|
||||
}
|
||||
|
||||
float WheeledVehicle::GetHandbrake()
|
||||
{
|
||||
return _handBrake;
|
||||
}
|
||||
|
||||
void WheeledVehicle::SetTankLeftThrottle(float value)
|
||||
{
|
||||
_tankLeftThrottle = Math::Clamp(value, -1.0f, 1.0f);
|
||||
@@ -387,6 +402,7 @@ void WheeledVehicle::DrawPhysicsDebug(RenderView& view)
|
||||
void WheeledVehicle::OnDebugDrawSelected()
|
||||
{
|
||||
// Wheels shapes
|
||||
int32 wheelIndex = 0;
|
||||
for (const auto& wheel : _wheels)
|
||||
{
|
||||
if (wheel.Collider && wheel.Collider->GetParent() == this && !wheel.Collider->GetIsTrigger())
|
||||
@@ -423,14 +439,20 @@ void WheeledVehicle::OnDebugDrawSelected()
|
||||
{
|
||||
DEBUG_DRAW_WIRE_SPHERE(BoundingSphere(data.State.TireContactPoint, 5.0f), Color::Green, 0, false);
|
||||
}
|
||||
if (ShowDebugDrawWheelNames)
|
||||
{
|
||||
const String text = String::Format(TEXT("Index: {}\nCollider: {}"), wheelIndex, wheel.Collider->GetName());
|
||||
DEBUG_DRAW_TEXT(text, currentPos, Color::Blue, 10, 0);
|
||||
}
|
||||
}
|
||||
wheelIndex++;
|
||||
}
|
||||
|
||||
// Anti roll bars axes
|
||||
const int32 wheelsCount = _wheels.Count();
|
||||
for (int32 i = 0; i < GetAntiRollBars().Count(); i++)
|
||||
for (int32 i = 0; i < _antiRollBars.Count(); i++)
|
||||
{
|
||||
const int32 axleIndex = GetAntiRollBars()[i].Axle;
|
||||
const int32 axleIndex = _antiRollBars[i].Axle;
|
||||
const int32 leftWheelIndex = axleIndex * 2;
|
||||
const int32 rightWheelIndex = leftWheelIndex + 1;
|
||||
if (leftWheelIndex >= wheelsCount || rightWheelIndex >= wheelsCount)
|
||||
|
||||
@@ -468,10 +468,18 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(1), EditorDisplay(\"Vehicle\")")
|
||||
bool UseAnalogSteering = false;
|
||||
|
||||
#if USE_EDITOR
|
||||
/// <summary>
|
||||
/// If checked, will draw wheel names and indices at the position of their colliders.
|
||||
/// </summary>
|
||||
API_FIELD(Attributes="EditorOrder(2), EditorDisplay(\"Vehicle\")")
|
||||
bool ShowDebugDrawWheelNames = false;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle driving model type.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(2), EditorDisplay(\"Vehicle\")") DriveTypes GetDriveType() const;
|
||||
API_PROPERTY(Attributes="EditorOrder(4), EditorDisplay(\"Vehicle\")") DriveTypes GetDriveType() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vehicle driving model type.
|
||||
@@ -481,12 +489,12 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the vehicle wheels settings.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(4), EditorDisplay(\"Vehicle\")") const Array<Wheel>& GetWheels() const;
|
||||
API_PROPERTY(Attributes="EditorOrder(5), EditorDisplay(\"Vehicle\")") const Array<Wheel>& GetWheels() const;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle drive control settings.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(5), EditorDisplay(\"Vehicle\")") DriveControlSettings GetDriveControl() const;
|
||||
API_PROPERTY(Attributes="EditorOrder(6), EditorDisplay(\"Vehicle\")") DriveControlSettings GetDriveControl() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vehicle drive control settings.
|
||||
@@ -501,7 +509,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the vehicle engine settings.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(6), EditorDisplay(\"Vehicle\")") EngineSettings GetEngine() const;
|
||||
API_PROPERTY(Attributes="EditorOrder(7), EditorDisplay(\"Vehicle\")") EngineSettings GetEngine() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vehicle engine settings.
|
||||
@@ -511,7 +519,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the vehicle differential settings.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(7), EditorDisplay(\"Vehicle\")") DifferentialSettings GetDifferential() const;
|
||||
API_PROPERTY(Attributes="EditorOrder(8), EditorDisplay(\"Vehicle\")") DifferentialSettings GetDifferential() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vehicle differential settings.
|
||||
@@ -521,7 +529,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the vehicle gearbox settings.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(8), EditorDisplay(\"Vehicle\")") GearboxSettings GetGearbox() const;
|
||||
API_PROPERTY(Attributes="EditorOrder(9), EditorDisplay(\"Vehicle\")") GearboxSettings GetGearbox() const;
|
||||
|
||||
/// <summary>
|
||||
/// Sets the vehicle gearbox settings.
|
||||
@@ -531,7 +539,7 @@ public:
|
||||
// <summary>
|
||||
/// Sets axles anti roll bars to increase vehicle stability.
|
||||
/// </summary>
|
||||
API_PROPERTY() void SetAntiRollBars(const Array<AntiRollBar>& value);
|
||||
API_PROPERTY(Attributes="EditorOrder(10), EditorDisplay(\"Vehicle\")") void SetAntiRollBars(const Array<AntiRollBar>& value);
|
||||
|
||||
// <summary>
|
||||
/// Gets axles anti roll bars.
|
||||
@@ -557,18 +565,36 @@ public:
|
||||
/// <param name="value">The value (-1,1 range).</param>
|
||||
API_FUNCTION() void SetSteering(float value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle steering. Steer is the analog steer value in range (-1,1) where -1 represents the steering wheel at left lock and +1 represents the steering wheel at right lock.
|
||||
/// </summary>
|
||||
/// <returns>The vehicle steering.</returns>
|
||||
API_FUNCTION() float GetSteering();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input for vehicle brakes. Brake is the analog brake pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
|
||||
/// </summary>
|
||||
/// <param name="value">The value (0,1 range).</param>
|
||||
API_FUNCTION() void SetBrake(float value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle brakes. Brake is the analog brake pedal value in range (0,1) where 1 represents the pedal fully pressed and 0 represents the pedal in its rest state.
|
||||
/// </summary>
|
||||
/// <returns>The vehicle brake.</returns>
|
||||
API_FUNCTION() float GetBrake();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input for vehicle handbrake. Handbrake is the analog handbrake value in range (0,1) where 1 represents the handbrake fully engaged and 0 represents the handbrake in its rest state.
|
||||
/// </summary>
|
||||
/// <param name="value">The value (0,1 range).</param>
|
||||
API_FUNCTION() void SetHandbrake(float value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the vehicle handbrake. Handbrake is the analog handbrake value in range (0,1) where 1 represents the handbrake fully engaged and 0 represents the handbrake in its rest state.
|
||||
/// </summary>
|
||||
/// <returns>The vehicle handbrake.</returns>
|
||||
API_FUNCTION() float GetHandbrake();
|
||||
|
||||
/// <summary>
|
||||
/// Sets the input for tank left track throttle. It is the analog accelerator pedal value in range (-1,1) where 1 represents the pedal fully pressed to move to forward, 0 to represents the
|
||||
/// pedal in its rest state and -1 represents the pedal fully pressed to move to backward. The track direction will be inverted if the vehicle current gear is rear.
|
||||
|
||||
@@ -246,7 +246,7 @@ void Collider::UpdateGeometry()
|
||||
const auto rigidBody = dynamic_cast<RigidBody*>(GetParent());
|
||||
if (_staticActor != nullptr || (rigidBody && CanAttach(rigidBody)))
|
||||
{
|
||||
PhysicsBackend::AttachShape(_shape, actor);
|
||||
Attach(rigidBody);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user