Compare commits

..

2 Commits

557 changed files with 47842 additions and 22271 deletions
+5 -5
View File
@@ -3,7 +3,7 @@ description: Downloads and installs Vulkan SDK.
inputs:
vulkan-version:
description: 'Vulkan SDK release version (e.g. 1.2.198.1).'
default: '1.4.350.0'
default: '1.3.290.0'
required: false
runs:
using: "composite"
@@ -24,13 +24,13 @@ runs:
;;
Darwin)
export VULKAN_SDK_ROOT=`pwd`/../VulkanSDK
curl -LO "https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/mac/vulkansdk-macos-$VULKAN_SDK_VER.zip"
unzip vulkansdk-macos-$VULKAN_SDK_VER.zip
sudo "vulkansdk-macos-$VULKAN_SDK_VER.app/Contents/MacOS/vulkansdk-macOS-$VULKAN_SDK_VER" --root $VULKAN_SDK_ROOT --accept-licenses --default-answer --confirm-command install
curl -LO "https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/mac/vulkan-sdk.dmg"
hdiutil attach vulkan-sdk.dmg -mountpoint /Volumes/vulkan-sdk
sudo "/Volumes/vulkan-sdk/InstallVulkan.app/Contents/MacOS/InstallVulkan" --root $VULKAN_SDK_ROOT --accept-licenses --default-answer --confirm-command install
export VULKAN_SDK=$VULKAN_SDK_ROOT/macOS
;;
*) # Windows
curl -L -o vulkan-sdk.exe https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/windows/vulkansdk-windows-X64-$VULKAN_SDK_VER.exe
curl -L -o vulkan-sdk.exe https://sdk.lunarg.com/sdk/download/$VULKAN_SDK_VER/windows/VulkanSDK-$VULKAN_SDK_VER-Installer.exe
./vulkan-sdk.exe --root "C:\VulkanSDK" --accept-licenses --default-answer --confirm-command install
export VULKAN_SDK="C:\VulkanSDK"
;;
+2 -2
View File
@@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.419
- name: Setup .NET Workload
run: |
dotnet workload install android
@@ -37,4 +37,4 @@ jobs:
PowerShell "(Get-Content global.json).Replace('latestMajor', 'minor') | Set-Content global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/global.json).Replace('latestMajor', 'minor') | Set-Content Source/Tools/Flax.Build/global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/Flax.Build.csproj).Replace('LatestMajor', 'Minor') | Set-Content Source/Tools/Flax.Build/Flax.Build.csproj"
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -printSDKs -dotnet=10 -arch=ARM64 -platform=Android -configuration=Release -buildtargets=FlaxGame
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -printSDKs -dotnet=8 -arch=ARM64 -platform=Android -configuration=Release -buildtargets=FlaxGame
+2 -2
View File
@@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 9.0.x
- name: Setup .NET Workload
run: |
dotnet workload install ios
@@ -33,4 +33,4 @@ jobs:
git lfs pull
- name: Build
run: |
./Development/Scripts/Mac/CallBuildTool.sh -build -log -dotnet=10 -arch=ARM64 -platform=iOS -configuration=Release -buildtargets=FlaxGame
./Development/Scripts/Mac/CallBuildTool.sh -build -log -dotnet=9 -arch=ARM64 -platform=iOS -configuration=Release -buildtargets=FlaxGame
+4 -4
View File
@@ -23,7 +23,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
@@ -34,7 +34,7 @@ jobs:
git lfs pull
- name: Build
run: |
./Development/Scripts/Linux/CallBuildTool.sh -build -log -printSDKs -dotnet=10 -arch=x64 -platform=Linux -configuration=Development -buildtargets=FlaxEditor
./Development/Scripts/Linux/CallBuildTool.sh -build -log -printSDKs -dotnet=8 -arch=x64 -platform=Linux -configuration=Development -buildtargets=FlaxEditor
# Game
game-linux:
@@ -52,7 +52,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
@@ -63,4 +63,4 @@ jobs:
git lfs pull
- name: Build
run: |
./Development/Scripts/Linux/CallBuildTool.sh -build -log -printSDKs -dotnet=10 -arch=x64 -platform=Linux -configuration=Release -buildtargets=FlaxGame
./Development/Scripts/Linux/CallBuildTool.sh -build -log -printSDKs -dotnet=8 -arch=x64 -platform=Linux -configuration=Release -buildtargets=FlaxGame
+4 -4
View File
@@ -19,7 +19,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
@@ -30,7 +30,7 @@ jobs:
git lfs pull
- name: Build
run: |
./Development/Scripts/Mac/CallBuildTool.sh -build -log -printSDKs -dotnet=10 -arch=ARM64 -platform=Mac -configuration=Development -buildtargets=FlaxEditor
./Development/Scripts/Mac/CallBuildTool.sh -build -log -printSDKs -dotnet=8 -arch=ARM64 -platform=Mac -configuration=Development -buildtargets=FlaxEditor
# Game
game-mac:
@@ -44,7 +44,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
@@ -55,4 +55,4 @@ jobs:
git lfs pull
- name: Build
run: |
./Development/Scripts/Mac/CallBuildTool.sh -build -log -printSDKs -dotnet=10 -arch=ARM64 -platform=Mac -configuration=Release -buildtargets=FlaxGame
./Development/Scripts/Mac/CallBuildTool.sh -build -log -printSDKs -dotnet=8 -arch=ARM64 -platform=Mac -configuration=Release -buildtargets=FlaxGame
+4 -4
View File
@@ -20,7 +20,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.419
- name: Print .NET info
run: |
dotnet --info
@@ -34,7 +34,7 @@ jobs:
PowerShell "(Get-Content global.json).Replace('latestMajor', 'minor') | Set-Content global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/global.json).Replace('latestMajor', 'minor') | Set-Content Source/Tools/Flax.Build/global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/Flax.Build.csproj).Replace('LatestMajor', 'Minor') | Set-Content Source/Tools/Flax.Build/Flax.Build.csproj"
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -printSDKs -dotnet=10 -arch=x64 -platform=Windows -configuration=Development -buildtargets=FlaxEditor
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -printSDKs -dotnet=8 -arch=x64 -platform=Windows -configuration=Development -buildtargets=FlaxEditor
# Game
game-windows:
@@ -48,7 +48,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.419
- name: Print .NET info
run: |
dotnet --info
@@ -62,4 +62,4 @@ jobs:
PowerShell "(Get-Content global.json).Replace('latestMajor', 'minor') | Set-Content global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/global.json).Replace('latestMajor', 'minor') | Set-Content Source/Tools/Flax.Build/global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/Flax.Build.csproj).Replace('LatestMajor', 'Minor') | Set-Content Source/Tools/Flax.Build/Flax.Build.csproj"
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -printSDKs -dotnet=10 -arch=x64 -platform=Windows -configuration=Release -buildtargets=FlaxGame
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -printSDKs -dotnet=8 -arch=x64 -platform=Windows -configuration=Release -buildtargets=FlaxGame
+12 -12
View File
@@ -28,7 +28,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.419
- name: Print .NET info
run: |
dotnet --info
@@ -38,7 +38,7 @@ jobs:
PowerShell "(Get-Content global.json).Replace('latestMajor', 'minor') | Set-Content global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/global.json).Replace('latestMajor', 'minor') | Set-Content Source/Tools/Flax.Build/global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/Flax.Build.csproj).Replace('LatestMajor', 'Minor') | Set-Content Source/Tools/Flax.Build/Flax.Build.csproj"
.\PackageEditor.bat -arch=x64 -platform=Windows -deployOutput=Output -dotnet=10
.\PackageEditor.bat -arch=x64 -platform=Windows -deployOutput=Output -dotnet=8
- name: Upload
uses: actions/upload-artifact@v7
with:
@@ -64,7 +64,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.419
- name: Print .NET info
run: |
dotnet --info
@@ -74,7 +74,7 @@ jobs:
PowerShell "(Get-Content global.json).Replace('latestMajor', 'minor') | Set-Content global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/global.json).Replace('latestMajor', 'minor') | Set-Content Source/Tools/Flax.Build/global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/Flax.Build.csproj).Replace('LatestMajor', 'Minor') | Set-Content Source/Tools/Flax.Build/Flax.Build.csproj"
.\PackagePlatforms.bat -arch=x64 -platform=Windows -deployOutput=Output -dotnet=10
.\PackagePlatforms.bat -arch=x64 -platform=Windows -deployOutput=Output -dotnet=8
- name: Upload
uses: actions/upload-artifact@v7
with:
@@ -101,14 +101,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
dotnet workload --info
- name: Build
run: |
./PackageEditor.sh -arch=x64 -platform=Linux -deployOutput=Output -dotnet=10
./PackageEditor.sh -arch=x64 -platform=Linux -deployOutput=Output -dotnet=8
- name: Upload
uses: actions/upload-artifact@v7
with:
@@ -133,14 +133,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
dotnet workload --info
- name: Build
run: |
./PackagePlatforms.sh -arch=x64 -platform=Linux -deployOutput=Output -dotnet=10
./PackagePlatforms.sh -arch=x64 -platform=Linux -deployOutput=Output -dotnet=8
- name: Upload
uses: actions/upload-artifact@v7
with:
@@ -163,14 +163,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
dotnet workload --info
- name: Build
run: |
./PackageEditor.command -arch=ARM64 -platform=Mac -deployOutput=Output -dotnet=10
./PackageEditor.command -arch=ARM64 -platform=Mac -deployOutput=Output -dotnet=8
- name: Upload
uses: actions/upload-artifact@v7
with:
@@ -191,14 +191,14 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
dotnet workload --info
- name: Build
run: |
./PackagePlatforms.command -arch=ARM64 -platform=Mac -deployOutput=Output -dotnet=10
./PackagePlatforms.command -arch=ARM64 -platform=Mac -deployOutput=Output -dotnet=8
- name: Upload
uses: actions/upload-artifact@v7
with:
+2 -2
View File
@@ -18,7 +18,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Setup .NET Workload
run: |
dotnet workload install ios
@@ -42,7 +42,7 @@ jobs:
cp ".github/data/Build Settings.json" "FlaxSamples/MaterialsFeaturesTour/Content/Settings"
- name: Build Editor
run: |
./Development/Scripts/Mac/CallBuildTool.sh -build -log -printSDKs -dotnet=10 -arch=ARM64 -platform=Mac -configuration=Development -buildtargets=FlaxEditor
./Development/Scripts/Mac/CallBuildTool.sh -build -log -printSDKs -dotnet=8 -arch=ARM64 -platform=Mac -configuration=Development -buildtargets=FlaxEditor
- name: Cook Game (iOS)
run: |
./Binaries/Editor/Mac/Development/FlaxEditor -std -headless -mute -null -project "FlaxSamples/MaterialsFeaturesTour" -build "Development.iOS"
+10 -10
View File
@@ -18,7 +18,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.x
- name: Print .NET info
run: |
dotnet --info
@@ -34,18 +34,18 @@ jobs:
chmod +x .github/data/bt.sh
- name: Build
run: |
./GenerateProjectFiles.sh -vs2026 -log -verbose -printSDKs -dotnet=10
./Development/Scripts/Linux/CallBuildTool.sh -build -log -dotnet=10 -arch=x64 -platform=Linux -configuration=Development -buildtargets=FlaxTestsTarget -UseLargeWorlds=true
./GenerateProjectFiles.sh -vs2022 -log -verbose -printSDKs -dotnet=8
./Development/Scripts/Linux/CallBuildTool.sh -build -log -dotnet=8 -arch=x64 -platform=Linux -configuration=Development -buildtargets=FlaxTestsTarget -UseLargeWorlds=true
dotnet msbuild Source/Tools/Flax.Build.Tests/Flax.Build.Tests.csproj /m /t:Restore,Build /p:Configuration=Debug /p:Platform=AnyCPU /nologo
dotnet msbuild Source/Tools/Flax.Build.Tests/Flax.Build.Tests.csproj /m /t:Restore,Build /p:Configuration=Debug /p:Platform=AnyCPU /nologo
- name: Test
run: |
${GITHUB_WORKSPACE}/.github/data/bt.sh ./Binaries/Editor/Linux/Development/FlaxTests -headless
dotnet test -f net10.0 Binaries/Tests/Flax.Build.Tests.dll
dotnet test -f net8.0 Binaries/Tests/Flax.Build.Tests.dll
cp Binaries/Editor/Linux/Development/FlaxEngine.CSharp.dll Binaries/Tests
cp Binaries/Editor/Linux/Development/FlaxEngine.CSharp.runtimeconfig.json Binaries/Tests
cp Binaries/Editor/Linux/Development/Newtonsoft.Json.dll Binaries/Tests
dotnet test -f net10.0 Binaries/Tests/FlaxEngine.CSharp.dll
dotnet test -f net8.0 Binaries/Tests/FlaxEngine.CSharp.dll
# Tests on Windows
tests-windows:
@@ -57,7 +57,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
dotnet-version: 8.0.419
- name: Print .NET info
run: |
dotnet --info
@@ -71,8 +71,8 @@ jobs:
PowerShell "(Get-Content global.json).Replace('latestMajor', 'minor') | Set-Content global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/global.json).Replace('latestMajor', 'minor') | Set-Content Source/Tools/Flax.Build/global.json"
PowerShell "(Get-Content Source/Tools/Flax.Build/Flax.Build.csproj).Replace('LatestMajor', 'Minor') | Set-Content Source/Tools/Flax.Build/Flax.Build.csproj"
.\GenerateProjectFiles.bat -vs2026 -log -verbose -printSDKs -dotnet=10
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -dotnet=10 -arch=x64 -platform=Windows -configuration=Development -buildtargets=FlaxTestsTarget
.\GenerateProjectFiles.bat -vs2022 -log -verbose -printSDKs -dotnet=8
.\Development\Scripts\Windows\CallBuildTool.bat -build -log -dotnet=8 -arch=x64 -platform=Windows -configuration=Development -buildtargets=FlaxTestsTarget
dotnet msbuild Source\Tools\Flax.Build.Tests\Flax.Build.Tests.csproj /m /t:Restore,Build /p:Configuration=Debug /p:Platform=AnyCPU /nologo
- name: Test
shell: pwsh
@@ -80,8 +80,8 @@ jobs:
$ErrorActionPreference = "Stop"
.\Binaries\Editor\Win64\Development\FlaxTests.exe -headless
if(!$?) { Write-Host "Tests failed with exit code $LastExitCode" -ForegroundColor Red; Exit $LastExitCode }
dotnet test -f net10.0 Binaries\Tests\Flax.Build.Tests.dll
dotnet test -f net8.0 Binaries\Tests\Flax.Build.Tests.dll
xcopy /y Binaries\Editor\Win64\Development\FlaxEngine.CSharp.dll Binaries\Tests
xcopy /y Binaries\Editor\Win64\Development\FlaxEngine.CSharp.runtimeconfig.json Binaries\Tests
xcopy /y Binaries\Editor\Win64\Development\Newtonsoft.Json.dll Binaries\Tests
dotnet test -f net10.0 Binaries\Tests\FlaxEngine.CSharp.dll
dotnet test -f net8.0 Binaries\Tests\FlaxEngine.CSharp.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+17
View File
@@ -0,0 +1,17 @@
## Mono
Custom fork: [https://github.com/FlaxEngine/mono](https://github.com/FlaxEngine/mono) with custom features for C# assemblies hot-reloading at runtime without domain unload (more: [https://flaxengine.com/blog/flax-facts-16-scripts-hot-reload/](https://flaxengine.com/blog/flax-facts-16-scripts-hot-reload/)).
Startup docs about building mono: [https://www.mono-project.com/docs/compiling-mono/](https://www.mono-project.com/docs/compiling-mono/)
### Notes
Some useful notes and tips for devs:
* Use `-monolog` to print Mono logs to Flax logs
* When working with mono fork set `localRepoPath` to local repo location in `Source\Tools\Flax.Build\Deps\Dependencies\mono.cs`
* To update mono deps when developing/updating use `.\Development\Scripts\Windows\CallBuildTool.bat -log -ReBuildDeps -verbose -depsToBuild=mono -platform=Windows`, then build engine and run it
* `MONO_GC_DEBUG=check-remset-consistency` - it will do additional checks at each collection to see if there are any missing write barriers
* `MONO_GC_DEBUG=nursery-canaries` - it might catch some buffer overflows in case of problems in code.
* `MONO_GC_DEBUG=<log-level>:<log-file>` - will print GC debug to the log file (eg. `4:sgen-gc`).
* Methods `mono_custom_attrs_from_property` and `mono_custom_attrs_get_attr` are internally cached
* If C++ mono call a method in c# that will throw an error, error will be handled but, not completly. Calling relase domain will return random `Access memory violation`. First search for error in c# code. No workaround yet.
@@ -34,7 +34,7 @@ goto Exit
echo CallBuildTool ERROR: The script is in invalid directory.
goto Exit
:Error_NoVisualStudioEnvironment
echo CallBuildTool ERROR: Missing Visual Studio 2026 or newer.
echo CallBuildTool ERROR: Missing Visual Studio 2022 or newer.
goto Exit
:Error_CompilationFailed
echo CallBuildTool ERROR: Failed to compile Flax.Build project.
+3 -3
View File
@@ -2,9 +2,9 @@
"Name": "Flax",
"Version": {
"Major": 1,
"Minor": 13,
"Minor": 12,
"Revision": 0,
"Build": 7005
"Build": 6914
},
"Company": "Flax",
"Copyright": "Copyright (c) 2012-2026 Wojciech Figat. All rights reserved.",
@@ -13,7 +13,7 @@
"Configuration": {
"UseCSharp": true,
"UseLargeWorlds": false,
"UseReverseZ": true,
"UseDotNet": true,
"Windows": {
"UseSDL": false,
},
-1
View File
@@ -257,7 +257,6 @@
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/GrammarAndSpelling/GrammarChecking/Exceptions/=Try_0020to_0020scripting/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/GrammarAndSpelling/GrammarChecking/Exceptions/=will_0020fallback/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/GrammarAndSpelling/GrammarChecking/RulesStates/=LanguageTool_002EEN_002EE_005FG/@EntryIndexedValue">DisabledByUser</s:String>
<s:Boolean x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=EEA05B0ED8200E4BA9D2D3F1052EBFFD/@KeyIndexDefined">True</s:Boolean>
<s:String x:Key="/Default/PatternsAndTemplates/Todo/TodoPatterns/=EEA05B0ED8200E4BA9D2D3F1052EBFFD/Color/@EntryValue">Blue</s:String>
+12 -12
View File
@@ -28,10 +28,10 @@ Follow the instructions below to compile and run the engine from source.
## Windows
* Install Visual Studio 2026 or newer
* Install Windows 10 SDK or newer (via Visual Studio Installer)
* Install Visual Studio 2022 or newer
* Install Windows 8.1 SDK or newer (via Visual Studio Installer)
* Install Microsoft Visual C++ 2015 v140 toolset or newer (via Visual Studio Installer)
* Install .NET 10 SDK (or newer) for **Windows x64** (via Visual Studio Installer or [from web](https://dotnet.microsoft.com/en-us/download/dotnet/10.0))
* Install .NET 8 SDK (or newer) for **Windows x64** (via Visual Studio Installer or [from web](https://dotnet.microsoft.com/en-us/download/dotnet/8.0))
* Install Git with LFS
* Clone repo (with LFS)
* Run **GenerateProjectFiles.bat**
@@ -44,10 +44,10 @@ Follow the instructions below to compile and run the engine from source.
## Linux
* Install Visual Studio Code
* Install .NET 10 SDK (or newer) ([https://dotnet.microsoft.com/en-us/download/dotnet/10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0))
* Ubuntu: `sudo apt install dotnet-sdk-10.0`
* Fedora: `sudo dnf install dotnet-sdk-10.0`
* Arch: `sudo pacman -S dotnet-sdk-10.0 dotnet-runtime-10.0 dotnet-targeting-pack-10.0 dotnet-host`
* Install .NET 8 or 9 SDK ([https://dotnet.microsoft.com/en-us/download/dotnet/8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0))
* Ubuntu: `sudo apt install dotnet-sdk-8.0`
* Fedora: `sudo dnf install dotnet-sdk-8.0`
* Arch: `sudo pacman -S dotnet-sdk-8.0 dotnet-runtime-8.0 dotnet-targeting-pack-8.0 dotnet-host`
* Install Vulkan SDK ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/))
* Ubuntu: `sudo apt install vulkan-sdk` (deprecated, follow official docs)
* Fedora: `sudo dnf install vulkan-headers vulkan-tools vulkan-validation-layers`
@@ -73,7 +73,7 @@ Follow the instructions below to compile and run the engine from source.
## Mac
* Install XCode 16.4 (or newer)
* Install .NET 10 SDK (or newer) ([https://dotnet.microsoft.com/en-us/download/dotnet/10.0](https://dotnet.microsoft.com/en-us/download/dotnet/10.0))
* Install .NET 8 SDK (or newer) ([https://dotnet.microsoft.com/en-us/download/dotnet/8.0](https://dotnet.microsoft.com/en-us/download/dotnet/8.0))
* Install Vulkan SDK ([https://vulkan.lunarg.com/](https://vulkan.lunarg.com/))
* Clone repo (with LFS)
* Run `GenerateProjectFiles.command`
@@ -86,17 +86,17 @@ Follow the instructions below to compile and run the engine from source.
Restart PC - ensure DotNet is added to PATH for command line tools execution.
* `Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 10.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 10.0`
* `Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 8.0`
Use Visual Studio 2026 (or newer), old Visual Studio versions are not supported by .NET SDK 10.
Use Visual Studio 2022, older versions are not supported by .NET SDK 8.
* `Building for Windows without Vulkan rendering backend (Vulkan SDK is missing)`
Install the Vulkan SDK then set an environment variable to provide the path to the SDK prior to running GenerateProjectFiles.bat: `set VULKAN_SDK=%sdk_path%`.
* `The NuGetSdkResolver did not resolve this SDK` / `Could not resolve SDK "Microsoft.NET.Sdk"`
* `The NuGetSdkResolver did not resolve this SDK`
Install `.NET SDK` 10, `NuGet package manager` and `NuGet targets and build tasks` in Visual Studio components.
Install `.NET SDK`, `NuGet package manager` and `NuGet targets and build tasks` in Visual Studio components.
## Workspace directory
@@ -160,7 +160,7 @@ namespace FlaxEditor.Content
}
else
{
_parameters = Array.Empty<ScriptMemberInfo.Parameter>();
_parameters = Utils.GetEmptyArray<ScriptMemberInfo.Parameter>();
}
}
@@ -283,9 +283,9 @@ namespace FlaxEditor.Content
{
if (!_asset)
{
_parameters = Array.Empty<ScriptMemberInfo>();
_methods = Array.Empty<ScriptMemberInfo>();
_attributes = Array.Empty<Attribute>();
_parameters = Utils.GetEmptyArray<ScriptMemberInfo>();
_methods = Utils.GetEmptyArray<ScriptMemberInfo>();
_attributes = Utils.GetEmptyArray<Attribute>();
return;
}
if (_parameters != null)
@@ -303,7 +303,7 @@ namespace FlaxEditor.Content
_parameters[i] = new ScriptMemberInfo(new VisualScriptParameterInfo(this, parameters[i]));
}
else
_parameters = Array.Empty<ScriptMemberInfo>();
_parameters = Utils.GetEmptyArray<ScriptMemberInfo>();
// Cache Visual Script methods info
var methodsCount = _asset.GetMethodsCount();
@@ -314,7 +314,7 @@ namespace FlaxEditor.Content
_methods[i] = new ScriptMemberInfo(new VisualScriptMethodInfo(this, i));
}
else
_methods = Array.Empty<ScriptMemberInfo>();
_methods = Utils.GetEmptyArray<ScriptMemberInfo>();
// Cache Visual Script attributes
{
@@ -525,7 +525,7 @@ namespace FlaxEditor.Content
var baseType = BaseType;
if (baseType)
return baseType.GetProperties(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
-5
View File
@@ -360,11 +360,6 @@ public:
/// </summary>
Array<BinaryModuleInfo, InlinedAllocation<64>> BinaryModules;
/// <summary>
/// Cached version of the built binaries from project Version Control.
/// </summary>
String VersionControlInfo;
public:
/// <summary>
@@ -42,13 +42,6 @@ bool CompileScriptsStep::DeployBinaries(CookingData& data, const String& path, c
return true;
}
// Metadata
auto versionControlInfoMember = document.FindMember("VersionControlInfo");
if (versionControlInfoMember != document.MemberEnd() && data.VersionControlInfo.IsEmpty())
{
data.VersionControlInfo = versionControlInfoMember->value.GetText();
}
// Deploy all references
auto referencesMember = document.FindMember("References");
if (referencesMember != document.MemberEnd())
@@ -252,15 +245,8 @@ bool CompileScriptsStep::Perform(CookingData& data)
writer.String(target);
writer.JKEY("Platform");
writer.String(platform);
writer.JKEY("Architecture");
writer.String(architecture);
writer.JKEY("Configuration");
writer.String(configuration);
if (data.VersionControlInfo.HasChars())
{
writer.JKEY("VersionControlInfo");
writer.String(data.VersionControlInfo);
}
writer.JKEY("BinaryModules");
writer.StartArray();
+1 -11
View File
@@ -50,10 +50,6 @@
#endif
#include "FlaxEngine.Gen.h"
#ifndef REVERSE_Z
#define REVERSE_Z 0
#endif
Dictionary<String, CookAssetsStep::ProcessAssetFunc> CookAssetsStep::AssetProcessors;
void IBuildCache::InvalidateCacheShaders()
@@ -237,11 +233,6 @@ void CookAssetsStep::CacheData::Load(CookingData& data)
LOG(Info, "{0} option has been modified.", TEXT("ShadersGenerateDebugData"));
invalidateShaders = true;
}
if (REVERSE_Z != Settings.Global.ShadersReverseZ)
{
LOG(Info, "{0} option has been modified.", TEXT("ShadersReverseZ"));
invalidateShaders = true;
}
#if PLATFORM_TOOLS_WINDOWS
if (data.Platform == BuildPlatform::Windows32 || data.Platform == BuildPlatform::Windows64)
{
@@ -433,7 +424,6 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
options.GenerateDebugData = data.Cache.Settings.Global.ShadersGenerateDebugData;
options.TreatWarningsAsErrors = false;
options.Output = &cacheStream;
options.Platform = data.Data.Tools->GetPlatform();
Array<String> includes;
#define COMPILE_PROFILE(profile, cacheChunk) \
@@ -536,6 +526,7 @@ bool ProcessShaderBase(CookAssetsStep::AssetCookData& data, ShaderAssetBase* ass
#if PLATFORM_TOOLS_XBOX_SCARLETT
case BuildPlatform::XboxScarlett:
{
options.Platform = PlatformType::XboxScarlett;
const char* platformDefineName = "PLATFORM_XBOX_SCARLETT";
COMPILE_PROFILE(DirectX_SM6, SHADER_FILE_CHUNK_INTERNAL_D3D_SM6_CACHE);
break;
@@ -1085,7 +1076,6 @@ bool CookAssetsStep::Perform(CookingData& data)
{
cache.Settings.Global.ShadersNoOptimize = buildSettings->ShadersNoOptimize;
cache.Settings.Global.ShadersGenerateDebugData = buildSettings->ShadersGenerateDebugData;
cache.Settings.Global.ShadersReverseZ = REVERSE_Z;
cache.Settings.Global.StreamingSettingsAssetId = gameSettings->Streaming;
cache.Settings.Global.ShadersVersion = GPU_SHADER_CACHE_VERSION;
cache.Settings.Global.MaterialGraphVersion = MATERIAL_GRAPH_VERSION;
@@ -97,7 +97,6 @@ public:
{
bool ShadersNoOptimize;
bool ShadersGenerateDebugData;
bool ShadersReverseZ;
Guid StreamingSettingsAssetId;
int32 ShadersVersion;
int32 MaterialGraphVersion;
@@ -30,6 +30,13 @@ bool DeployDataStep::Perform(CookingData& data)
Platform::Sleep(10);
}
FileSystem::CreateDirectory(contentDir);
const String dstMono = data.DataOutputPath / TEXT("Mono");
#if USE_NETCORE
{
// Remove old Mono files
FileSystem::DeleteDirectory(dstMono);
FileSystem::DeleteFile(data.DataOutputPath / TEXT("MonoPosixHelper.dll"));
}
String dstDotnet = data.DataOutputPath / TEXT("Dotnet");
const DotNetAOTModes aotMode = data.Tools->UseAOT();
const bool usAOT = aotMode != DotNetAOTModes::None && aotMode != DotNetAOTModes::NoDotnet;
@@ -379,6 +386,23 @@ bool DeployDataStep::Perform(CookingData& data)
}
}
}
#else
if (!FileSystem::DirectoryExists(dstMono))
{
// Deploy Mono files (from platform data folder)
const String srcMono = depsRoot / TEXT("Mono");
if (!FileSystem::DirectoryExists(srcMono))
{
data.Error(TEXT("Missing Mono runtime data files."));
return true;
}
if (FileSystem::CopyDirectory(dstMono, srcMono))
{
data.Error(TEXT("Failed to copy Mono runtime data files."));
return true;
}
}
#endif
// Deploy engine data for the target platform
if (data.Tools->OnDeployBinaries(data))
@@ -52,15 +52,16 @@ void OnAssemblyLoaded(MAssembly* assembly);
void OnAssemblyUnloading(MAssembly* assembly);
void OnBinaryModuleLoaded(BinaryModule* module);
MType* CustomEditorsUtil::GetCustomEditor(MType* type)
MTypeObject* CustomEditorsUtil::GetCustomEditor(MTypeObject* refType)
{
if (!type)
if (!refType)
return nullptr;
MType* type = INTERNAL_TYPE_OBJECT_GET(refType);
Entry result;
if (Cache.TryGet(type, result))
{
if (result.CustomEditorType)
return result.CustomEditorType;
return INTERNAL_TYPE_GET_OBJECT(result.CustomEditorType);
MClass* editor = result.CustomEditor ? result.CustomEditor : result.DefaultEditor;
if (editor)
return MUtils::GetType(editor);
@@ -126,8 +127,12 @@ void OnAssemblyLoaded(MAssembly* assembly)
continue;
// Check if attribute references a valid class
MType* type = nullptr;
customEditorTypeField->GetValue(attribute, &type);
MTypeObject* refType = nullptr;
customEditorTypeField->GetValue(attribute, &refType);
if (refType == nullptr)
continue;
MType* type = INTERNAL_TYPE_OBJECT_GET(refType);
if (type == nullptr)
continue;
MClass* typeClass = MCore::Type::GetClass(type);
@@ -12,6 +12,6 @@ class CustomEditorsUtil
public:
#if USE_CSHARP
static MType* GetCustomEditor(MType* type);
static MTypeObject* GetCustomEditor(MTypeObject* refType);
#endif
};
@@ -261,7 +261,6 @@ namespace FlaxEditor.CustomEditors.Editors
public static List<ItemInfo> GetItemsForType(ScriptType type, bool useProperties, bool useFields, bool usePropertiesWithoutSetter = false)
{
var items = new List<ItemInfo>();
var isPlayMode = Editor.IsPlayMode;
if (useProperties)
{
@@ -279,7 +278,7 @@ namespace FlaxEditor.CustomEditors.Editors
continue;
// Skip hidden fields, handle special attributes
if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute hide && (!isPlayMode || !hide.ShowInPlayMode)))
if ((!p.IsPublic && !showInEditor) || attributes.Any(x => x is HideInEditorAttribute))
continue;
items.Add(new ItemInfo(p, attributes));
@@ -294,10 +293,11 @@ namespace FlaxEditor.CustomEditors.Editors
for (int i = 0; i < fields.Length; i++)
{
var f = fields[i];
var attributes = f.GetAttributes(true);
// Skip hidden fields, handle special attributes
if ((!f.IsPublic && !attributes.Any(x => x is ShowInEditorAttribute)) || attributes.Any(x => x is HideInEditorAttribute hide && (!isPlayMode || !hide.ShowInPlayMode)))
if ((!f.IsPublic && !attributes.Any(x => x is ShowInEditorAttribute)) || attributes.Any(x => x is HideInEditorAttribute))
continue;
items.Add(new ItemInfo(f, attributes));
@@ -679,7 +679,7 @@ namespace FlaxEditor.CustomEditors.Editors
return asArray;
if (Values[0] is List<Tag> asList)
return asList.ToArray();
return Array.Empty<Tag>();
return Utils.GetEmptyArray<Tag>();
}
set
{
@@ -1,90 +0,0 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEngine;
using FlaxEngine.GUI;
using System;
namespace FlaxEditor.CustomEditors.Editors
{
/// <summary>
/// Default implementation of the inspector used to edit TimeSpan value type properties.
/// </summary>
[CustomEditor(typeof(TimeSpan)), DefaultEditor]
class TimeSpanEditor : CustomEditor
{
private TextBox _textBox;
private bool _isRefreshing;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
if (HasDifferentTypes)
return;
_textBox = layout.Custom<TextBox>().CustomControl;
_textBox.EditEnd += OnEditEnd;
}
private void OnEditEnd()
{
if (_isRefreshing)
return;
if (TimeSpan.TryParse(_textBox.Text, out var timeSpan))
SetValue(timeSpan);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
_isRefreshing = true;
_textBox.Text = HasDifferentValues ? "Multiple Values" : ((TimeSpan)Values[0]).ToString("G");
_isRefreshing = false;
}
}
/// <summary>
/// Default implementation of the inspector used to edit DateTime value type properties.
/// </summary>
[CustomEditor(typeof(DateTime)), DefaultEditor]
class DateTimeEditor : CustomEditor
{
private TextBox _textBox;
private bool _isRefreshing;
/// <inheritdoc />
public override DisplayStyle Style => DisplayStyle.Inline;
/// <inheritdoc />
public override void Initialize(LayoutElementsContainer layout)
{
if (HasDifferentTypes)
return;
_textBox = layout.Custom<TextBox>().CustomControl;
_textBox.EditEnd += OnEditEnd;
}
private void OnEditEnd()
{
if (_isRefreshing)
return;
if (DateTime.TryParse(_textBox.Text, out var timeSpan))
SetValue(timeSpan);
}
/// <inheritdoc />
public override void Refresh()
{
base.Refresh();
_isRefreshing = true;
_textBox.Text = HasDifferentValues ? "Multiple Values" : ((DateTime)Values[0]).ToString("g");
_isRefreshing = false;
}
}
}
+1 -3
View File
@@ -12,8 +12,6 @@ using Microsoft.Win32;
/// </summary>
public class Editor : EditorModule
{
private static bool _logDotnetVersionsRange;
private void AddPlatformTools(BuildOptions options, string platformToolsRoot, string platformToolsRootExternal, string platform, params string[] macros)
{
if (Directory.Exists(Path.Combine(platformToolsRoot, platform)))
@@ -109,7 +107,7 @@ public class Editor : EditorModule
var maxVer = DotNetSdk.MaximumVersion.Major;
options.PrivateDefinitions.Add("GAME_BUILD_DOTNET_RUNTIME_MIN_VER=" + minVer);
options.PrivateDefinitions.Add("GAME_BUILD_DOTNET_RUNTIME_MAX_VER=" + DotNetSdk.MaximumVersion.Major);
Log.VerboseOnce($"Using Dotnet runtime versions range {minVer}-{maxVer} for Game Cooker", ref _logDotnetVersionsRange);
Log.Verbose($"Using Dotnet runtime versions range {minVer}-{maxVer} for Game Cooker");
}
}
+1 -10
View File
@@ -486,15 +486,6 @@ namespace FlaxEditor.GUI
button.TooltipText = _tooltips[index];
}
/// <summary>
/// Gets the text for selected item(s).
/// </summary>
/// <returns>The display text.</returns>
protected virtual string GetSelectedText()
{
return _selectedIndices.Count == 1 ? (_selectedIndices[0] >= 0 && _selectedIndices[0] < _items.Count ? _items[_selectedIndices[0]] : "") : "Multiple Values";
}
/// <summary>
/// Creates the popup menu.
/// </summary>
@@ -563,7 +554,7 @@ namespace FlaxEditor.GUI
// Check if has selected item
if (_selectedIndices != null && _selectedIndices.Count > 0)
{
string text = GetSelectedText();
string text = _selectedIndices.Count == 1 ? (_selectedIndices[0] >= 0 && _selectedIndices[0] < _items.Count ? _items[_selectedIndices[0]] : "") : "Multiple Values";
// Draw text of the selected item
float textScale = Height / DefaultHeight;
+1 -1
View File
@@ -103,7 +103,7 @@ namespace FlaxEditor.GUI.Drag
return results;
}
}
return Array.Empty<ScriptType>();
return Utils.GetEmptyArray<ScriptType>();
}
}
}
+1 -1
View File
@@ -101,7 +101,7 @@ public class DragControlType<U> : DragHelper<ScriptType, U> where U : DragEventA
return results;
}
}
return Array.Empty<ScriptType>();
return Utils.GetEmptyArray<ScriptType>();
}
}
+1 -1
View File
@@ -103,7 +103,7 @@ namespace FlaxEditor.GUI.Drag
return results.ToArray();
}
}
return Array.Empty<Script>();
return Utils.GetEmptyArray<Script>();
}
/// <summary>
+43 -37
View File
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using FlaxEditor.CustomEditors;
using FlaxEditor.CustomEditors.Elements;
using FlaxEditor.GUI.ContextMenu;
using FlaxEditor.Scripting;
@@ -105,6 +106,16 @@ namespace FlaxEditor.GUI
if (_cachedValue == value && _hasValueCached)
return;
// Single value
for (int i = 0; i < _entries.Count; i++)
{
if (_entries[i].Value == value)
{
SelectedIndex = i;
return;
}
}
if (IsFlags)
{
// Collection of flags
@@ -112,7 +123,7 @@ namespace FlaxEditor.GUI
for (int i = 0; i < _entries.Count; i++)
{
var e = _entries[i].Value;
if ((e != 0 || value == 0) && (e & value) == e)
if (e != 0 && (e & value) == e)
{
selection.Add(i);
}
@@ -121,17 +132,7 @@ namespace FlaxEditor.GUI
}
else
{
// Single value
var toSelect = -1;
for (int i = 0; i < _entries.Count; i++)
{
if (_entries[i].Value == value)
{
toSelect = i;
break;
}
}
SelectedIndex = toSelect;
SelectedIndex = -1;
}
}
}
@@ -294,22 +295,6 @@ namespace FlaxEditor.GUI
button.CloseMenuOnClick = false;
}
/// <inheritdoc />
protected override string GetSelectedText()
{
// If multiple values are selected then try to find an enum item that matches the mask value
if (_selectedIndices.Count > 1)
{
foreach (var e in _entries)
{
if (e.Value == Value)
return e.Name;
}
}
return base.GetSelectedText();
}
/// <inheritdoc />
protected override void OnItemClicked(int index)
{
@@ -325,22 +310,43 @@ namespace FlaxEditor.GUI
}
// Calculate value that will be set after change
long valueAfter = Value;
long valueAfter = 0;
bool isSelected = _selectedIndices.Contains(index);
long selectedValue = entries[index].Value;
if (isSelected)
for (int i = 0; i < _selectedIndices.Count; i++)
{
// Remove from flags selection
valueAfter &= ~selectedValue;
int selectedIndex = _selectedIndices[i];
if (selectedIndex != index && (isSelected || (entries[selectedIndex].Value & selectedValue) == 0))
valueAfter |= entries[selectedIndex].Value;
}
else
{
// Add to flags selection
if (!isSelected)
valueAfter |= selectedValue;
// Skip if value won't change
if (Value == valueAfter)
{
return;
}
// Change value (incl. multiselection for flags)
Value = valueAfter;
// Build new selection
for (int i = 0; i < entries.Count; i++)
{
if (entries[i].Value == valueAfter)
{
SelectedIndex = i;
return;
}
}
_selectedIndices.Clear();
for (int i = 0; i < entries.Count; i++)
{
var e = entries[i].Value;
if (e != 0 && (e & valueAfter) == e)
{
_selectedIndices.Add(i);
}
}
OnSelectedIndexChanged();
return;
}
@@ -146,12 +146,12 @@ namespace FlaxEditor.GUI.Timeline.Tracks
/// <summary>
/// The event parameters data sizes collection.
/// </summary>
public int[] EventParamsSizes = Array.Empty<int>();
public int[] EventParamsSizes = Utils.GetEmptyArray<int>();
/// <summary>
/// The event parameters types collection.
/// </summary>
public Type[] EventParamsTypes = Array.Empty<Type>();
public Type[] EventParamsTypes = Utils.GetEmptyArray<Type>();
/// <summary>
/// The event key data.
@@ -380,7 +380,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
}
else
{
EventParamsTypes = Array.Empty<Type>();
EventParamsTypes = Utils.GetEmptyArray<Type>();
}
OnEventParamsChanged();
}
+5 -1
View File
@@ -139,11 +139,15 @@ namespace FlaxEditor.Gizmo
DrawSelectionDepth(context, renderContext.Task, customDepth);
_actors.Clear();
var near = renderContext.View.Near;
var far = renderContext.View.Far;
var projection = renderContext.View.Projection;
// Render outline
_material.SetParameterValue("OutlineColor0", _color0);
_material.SetParameterValue("OutlineColor1", _color1);
_material.SetParameterValue("CustomDepth", customDepth);
_material.SetParameterValue("ViewInfo", renderContext.View.ViewInfo);
_material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, far / (far - near), (-far * near) / (far - near) / far));
Renderer.DrawPostFxMaterial(context, ref renderContext, _material, output, input.View());
// Cleanup
@@ -526,7 +526,7 @@ DEFINE_INTERNAL_CALL(void) EditorInternal_SetAnimationTime(AnimatedModel* animat
animatedModel->GraphInstance.State[0].Animation.TimePosition = time;
}
DEFINE_INTERNAL_CALL(MType*) CustomEditorsUtilInternal_GetCustomEditor(MType* targetType)
DEFINE_INTERNAL_CALL(MTypeObject*) CustomEditorsUtilInternal_GetCustomEditor(MTypeObject* targetType)
{
return CustomEditorsUtil::GetCustomEditor(targetType);
}
+10 -16
View File
@@ -24,7 +24,7 @@ namespace FlaxEditor.Modules
private bool _rebuildInitFlag;
private int _itemsCreated;
private int _itemsDeleted;
private readonly HashSet<ContentFolderTreeNode> _dirtyNodes = new HashSet<ContentFolderTreeNode>();
private readonly HashSet<MainContentFolderTreeNode> _dirtyNodes = new HashSet<MainContentFolderTreeNode>();
/// <summary>
/// The project directory.
@@ -1309,31 +1309,26 @@ namespace FlaxEditor.Modules
internal void OnDirectoryEvent(MainContentFolderTreeNode node, FileSystemEventArgs e)
{
// Ignore events during fast setup
// Ensure to be ready for external events
if (_isDuringFastSetup)
return;
ContentFolderTreeNode dirtyNode = node;
// Filter the node based on modified path
// (eg. if we have event for 'Content/Folder1/Folder2' and node is 'Content/Folder1' then we should process but skip other 'Content' subfolders)
var path = StringUtils.NormalizePath(Path.GetDirectoryName(e.FullPath));
var pathItem = node.Folder.Find(path) as ContentFolder;
if (pathItem != null)
{
dirtyNode = pathItem.Node;
}
// TODO: maybe we could make it faster! since we have a path so it would be easy to just create or delete given file. but remember about subdirectories
// Switch type
switch (e.ChangeType)
{
case WatcherChangeTypes.Created:
case WatcherChangeTypes.Deleted:
case WatcherChangeTypes.Renamed:
{
lock (_dirtyNodes)
{
_dirtyNodes.Add(dirtyNode);
_dirtyNodes.Add(node);
}
break;
}
}
}
private void OnScriptsReload()
@@ -1388,15 +1383,14 @@ namespace FlaxEditor.Modules
// Update all dirty content tree nodes
lock (_dirtyNodes)
{
Profiler.BeginEvent("ContentDatabase.Refresh");
foreach (var node in _dirtyNodes)
{
LoadFolder(node, true);
if (_enableEvents)
WorkspaceModified?.Invoke();
}
if (_enableEvents && _dirtyNodes.Count != 0)
WorkspaceModified?.Invoke();
_dirtyNodes.Clear();
Profiler.EndEvent();
}
// Lazy-rebuilds
@@ -381,6 +381,9 @@ namespace FlaxEditor.Modules
Thread.Sleep(0);
_workerThread.Join(1000);
#if !USE_NETCORE
_workerThread.Abort(); // Deprecated in .NET 7
#endif
_workerThread = null;
}
@@ -584,6 +584,7 @@ namespace FlaxEditor.Modules.SourceCodeEditing
var codeBase = Utils.GetAssemblyLocation(assembly);
if (string.IsNullOrEmpty(codeBase))
return true;
#if USE_NETCORE
if (assembly.ManifestModule.FullyQualifiedName == "<In Memory Module>")
return false;
@@ -591,6 +592,11 @@ namespace FlaxEditor.Modules.SourceCodeEditing
string repositoryUrl = assembly.GetCustomAttributes<AssemblyMetadataAttribute>().FirstOrDefault(x => x.Key == "RepositoryUrl")?.Value ?? "";
if (repositoryUrl != "https://github.com/dotnet/runtime")
return true;
#else
// Skip assemblies from in-build Mono directory
if (!codeBase.Contains("/Mono/lib/mono/"))
return true;
#endif
return false;
}
-2
View File
@@ -465,8 +465,6 @@ namespace FlaxEditor.Modules
internal void ProgressFailed(string message)
{
if (StatusBar == null)
return;
_progressFailed = true;
StatusBar.StatusColor = Style.Current.Statusbar.Failed;
StatusBar.Text = message;
@@ -278,7 +278,7 @@ String RiderCodeEditor::GetName() const
String RiderCodeEditor::GetGenerateProjectCustomArgs() const
{
return TEXT("-vs2026");
return TEXT("-vs2022");
}
void RiderCodeEditor::OpenFile(const String& path, int32 line)
@@ -130,7 +130,7 @@ String VisualStudioCodeEditor::GetName() const
String VisualStudioCodeEditor::GetGenerateProjectCustomArgs() const
{
return TEXT("-vs2026 -vscode");
return TEXT("-vs2022 -vscode");
}
void VisualStudioCodeEditor::OpenFile(const String& path, int32 line)
@@ -138,7 +138,7 @@ void VisualStudioCodeEditor::OpenFile(const String& path, int32 line)
// Generate VS solution files for intellisense
if (!FileSystem::FileExists(Globals::ProjectFolder / Editor::Project->Name + TEXT(".sln")))
{
ScriptsBuilder::GenerateProject(TEXT("-vs2026"));
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
}
// Generate project files if missing
@@ -165,7 +165,7 @@ void VisualStudioCodeEditor::OpenSolution()
// Generate VS solution files for intellisense
if (!FileSystem::FileExists(Globals::ProjectFolder / Editor::Project->Name + TEXT(".sln")))
{
ScriptsBuilder::GenerateProject(TEXT("-vs2026"));
ScriptsBuilder::GenerateProject(TEXT("-vs2022"));
}
// Generate project files if solution is missing
+6 -6
View File
@@ -112,37 +112,37 @@ namespace FlaxEditor.Scripting
/// <inheritdoc />
public object[] GetAttributes(bool inherit)
{
return Array.Empty<object>();
return Utils.GetEmptyArray<object>();
}
/// <inheritdoc />
public ScriptMemberInfo[] GetMembers(string name, MemberTypes type, BindingFlags bindingAttr)
{
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
public ScriptMemberInfo[] GetMembers(BindingFlags bindingAttr)
{
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
public ScriptMemberInfo[] GetFields(BindingFlags bindingAttr)
{
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
public ScriptMemberInfo[] GetProperties(BindingFlags bindingAttr)
{
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
public ScriptMemberInfo[] GetMethods(BindingFlags bindingAttr)
{
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <inheritdoc />
+12 -12
View File
@@ -447,7 +447,7 @@ namespace FlaxEditor.Scripting
{
var parameters = methodInfo.GetParameters();
if (parameters.Length == 0)
return Array.Empty<Parameter>();
return Utils.GetEmptyArray<Parameter>();
var result = new Parameter[parameters.Length];
for (int i = 0; i < result.Length; i++)
{
@@ -593,7 +593,7 @@ namespace FlaxEditor.Scripting
}
if (_custom != null)
return _custom.GetAttributes(inherit);
return Array.Empty<object>();
return Utils.GetEmptyArray<object>();
}
/// <summary>
@@ -1116,7 +1116,7 @@ namespace FlaxEditor.Scripting
return _managed.GetCustomAttributes(inherit);
if (_custom != null)
return _custom.GetAttributes(inherit);
return Array.Empty<object>();
return Utils.GetEmptyArray<object>();
}
/// <summary>
@@ -1191,12 +1191,12 @@ namespace FlaxEditor.Scripting
if (_managed != null)
{
managedMembers = _managed.GetMember(name, type, bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
managedMembers = null;
if (_custom != null)
return _custom.GetMembers(name, type, bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
@@ -1218,7 +1218,7 @@ namespace FlaxEditor.Scripting
}
if (_custom != null)
return _custom.GetMembers(name, type, bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
@@ -1282,12 +1282,12 @@ namespace FlaxEditor.Scripting
if (_managed != null)
{
managedMembers = _managed.GetMembers(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
managedMembers = null;
if (_custom != null)
return _custom.GetMembers(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
@@ -1307,7 +1307,7 @@ namespace FlaxEditor.Scripting
}
if (_custom != null)
return _custom.GetMembers(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
@@ -1327,7 +1327,7 @@ namespace FlaxEditor.Scripting
}
if (_custom != null)
return _custom.GetFields(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
@@ -1365,7 +1365,7 @@ namespace FlaxEditor.Scripting
}
if (_custom != null)
return _custom.GetProperties(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
@@ -1403,7 +1403,7 @@ namespace FlaxEditor.Scripting
}
if (_custom != null)
return _custom.GetMethods(bindingAttr);
return Array.Empty<ScriptMemberInfo>();
return Utils.GetEmptyArray<ScriptMemberInfo>();
}
/// <summary>
+15 -3
View File
@@ -141,10 +141,10 @@ int32 ScriptsBuilder::GetCompilationsCount()
String ScriptsBuilder::GetBuildToolPath()
{
#if PLATFORM_WINDOWS_FAMILY
return Globals::StartupFolder / TEXT("Binaries/Tools/Flax.Build.exe");
#else
#if USE_NETCORE && (PLATFORM_LINUX || PLATFORM_MAC)
return Globals::StartupFolder / TEXT("Binaries/Tools/Flax.Build");
#else
return Globals::StartupFolder / TEXT("Binaries/Tools/Flax.Build.exe");
#endif
}
@@ -244,6 +244,18 @@ bool ScriptsBuilder::RunBuildTool(const StringView& args, const StringView& work
// Prepare build options
StringBuilder cmdLine(args.Length() + buildToolPath.Length() + 200);
#if !USE_NETCORE && (PLATFORM_LINUX || PLATFORM_MAC)
const String monoPath = Globals::MonoPath / TEXT("bin/mono");
if (!FileSystem::FileExists(monoPath))
{
Log::FileNotFoundException(monoPath).SetLevel(LogType::Fatal);
return true;
}
const String monoPath = TEXT("mono");
cmdLine.Append(monoPath);
cmdLine.Append(TEXT(" "));
// TODO: Set env var for the mono MONO_GC_PARAMS=nursery-size64m to boost build performance -> profile it
#endif
cmdLine.Append(buildToolPath);
// Call build tool
+3 -3
View File
@@ -39,8 +39,8 @@ namespace FlaxEditor.Surface
DefaultValues = new object[]
{
"State",
Array.Empty<byte>(),
Array.Empty<byte>(),
Utils.GetEmptyArray<byte>(),
Utils.GetEmptyArray<byte>(),
},
Size = new Float2(100, 0),
},
@@ -54,7 +54,7 @@ namespace FlaxEditor.Surface
Size = new Float2(100, 0),
DefaultValues = new object[]
{
Array.Empty<byte>(),
Utils.GetEmptyArray<byte>(),
},
},
}
@@ -875,7 +875,7 @@ namespace FlaxEditor.Surface.Archetypes
byte[] value;
if (Transitions.Count == 0)
{
value = Array.Empty<byte>();
value = Utils.GetEmptyArray<byte>();
}
else
{
@@ -1807,7 +1807,7 @@ namespace FlaxEditor.Surface.Archetypes
get => _ruleGraph;
set
{
_ruleGraph = value ?? Array.Empty<byte>();
_ruleGraph = value ?? Utils.GetEmptyArray<byte>();
SourceState.SaveTransitions();
}
}
@@ -1849,7 +1849,7 @@ namespace FlaxEditor.Surface.Archetypes
DestinationState = destination;
_data = data;
_data.Destination = destination.ID;
_ruleGraph = ruleGraph ?? Array.Empty<byte>();
_ruleGraph = ruleGraph ?? Utils.GetEmptyArray<byte>();
}
/// <summary>
@@ -784,7 +784,7 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
"Locomotion",
Array.Empty<byte>(),
Utils.GetEmptyArray<byte>(),
3,
true,
true,
@@ -818,8 +818,8 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
"State",
Array.Empty<byte>(),
Array.Empty<byte>(),
Utils.GetEmptyArray<byte>(),
Utils.GetEmptyArray<byte>(),
},
},
new NodeArchetype
@@ -1089,7 +1089,7 @@ namespace FlaxEditor.Surface.Archetypes
Size = new Float2(100, 0),
DefaultValues = new object[]
{
Array.Empty<byte>(),
Utils.GetEmptyArray<byte>(),
},
},
new NodeArchetype
@@ -445,7 +445,7 @@ namespace FlaxEditor.Surface.Archetypes
var decorator = Context.SpawnNode(19, 3, Location, new object[]
{
nodeType.TypeName,
Array.Empty<byte>(),
Utils.GetEmptyArray<byte>(),
});
// Add decorator to the node
@@ -646,7 +646,7 @@ namespace FlaxEditor.Surface.Archetypes
return new[] { uint.Parse(id[0]) };
}
}
return Array.Empty<uint>();
return Utils.GetEmptyArray<uint>();
}
}
@@ -949,7 +949,7 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
string.Empty, // Type Name
Array.Empty<byte>(), // Instance Data
Utils.GetEmptyArray<byte>(), // Instance Data
null, // List of Decorator Nodes IDs
},
Size = new Float2(100, 0),
@@ -967,7 +967,7 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
typeof(BehaviorTreeRootNode).FullName, // Root node
Array.Empty<byte>(), // Instance Data
Utils.GetEmptyArray<byte>(), // Instance Data
},
Size = new Float2(100, 0),
Elements = new[]
@@ -984,7 +984,7 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
string.Empty, // Type Name
Array.Empty<byte>(), // Instance Data
Utils.GetEmptyArray<byte>(), // Instance Data
},
Size = new Float2(100, 0),
},
@@ -1,6 +1,5 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using FlaxEditor.GUI;
using FlaxEditor.Scripting;
@@ -85,7 +84,7 @@ namespace FlaxEditor.Surface.Archetypes
const int firstBox = 2;
const int maxBoxes = 40;
bool isInvalid = false;
var data = Array.Empty<byte>();
var data = Utils.GetEmptyArray<byte>();
if (valueBox.HasAnyConnection)
{
@@ -217,7 +216,7 @@ namespace FlaxEditor.Surface.Archetypes
Description = "Returns one of the input values based on the enum value",
Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
Size = new Float2(160, 60),
DefaultValues = new object[] { Array.Empty<byte>() },
DefaultValues = new object[] { Utils.GetEmptyArray<byte>() },
ConnectionsHints = ConnectionsHint.Enum,
Elements = new[]
{
+2 -3
View File
@@ -1,6 +1,5 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using System;
using System.Collections.Generic;
using FlaxEditor.GUI;
using FlaxEditor.Scripting;
@@ -141,7 +140,7 @@ namespace FlaxEditor.Surface.Archetypes
const int firstBox = 2;
const int maxBoxes = 40;
bool isInvalid = false;
var data = Array.Empty<byte>();
var data = Utils.GetEmptyArray<byte>();
if (valueBox.HasAnyConnection)
{
@@ -286,7 +285,7 @@ namespace FlaxEditor.Surface.Archetypes
Description = "Performs the flow logic branch based on the enum value",
Flags = NodeFlags.VisualScriptGraph,
Size = new Float2(160, 60),
DefaultValues = new object[] { Array.Empty<byte>() },
DefaultValues = new object[] { Utils.GetEmptyArray<byte>() },
ConnectionsHints = ConnectionsHint.Enum,
Elements = new[]
{
+7 -7
View File
@@ -574,7 +574,7 @@ namespace FlaxEditor.Surface.Archetypes
if (_parameters.Length == 0 && methodInfo.ValueType.IsVoid)
{
// Skip allocations if method is void and parameter-less
Values[2] = Array.Empty<byte>();
Values[2] = Utils.GetEmptyArray<byte>();
}
else
{
@@ -714,7 +714,7 @@ namespace FlaxEditor.Surface.Archetypes
method.Name, // Method name
parametersCount, // Method parameters count
false, // Is Pure?
Array.Empty<byte>(), // Cached function signature data
Utils.GetEmptyArray<byte>(), // Cached function signature data
// Default value for parameters (27 entries)
// @formatter:off
null,null,null,null,null,null,null,null,null,null,
@@ -810,7 +810,7 @@ namespace FlaxEditor.Surface.Archetypes
signature.IsStatic = reader.ReadBoolean(); // Is Static
signature.ReturnType = VariantUtils.ReadVariantScriptType(reader); // Return type
var parametersCount = reader.ReadInt32(); // Parameters count
signature.Params = parametersCount != 0 ? new SignatureParamInfo[parametersCount] : Array.Empty<SignatureParamInfo>();
signature.Params = parametersCount != 0 ? new SignatureParamInfo[parametersCount] : Utils.GetEmptyArray<SignatureParamInfo>();
for (int i = 0; i < parametersCount; i++)
{
ref var param = ref signature.Params[i];
@@ -831,7 +831,7 @@ namespace FlaxEditor.Surface.Archetypes
signature.IsStatic = reader.ReadBoolean(); // Is Static
signature.ReturnType = VariantUtils.ReadVariantScriptType(reader); // Return type
var parametersCount = reader.ReadInt32(); // Parameters count
signature.Params = parametersCount != 0 ? new SignatureParamInfo[parametersCount] : Array.Empty<SignatureParamInfo>();
signature.Params = parametersCount != 0 ? new SignatureParamInfo[parametersCount] : Utils.GetEmptyArray<SignatureParamInfo>();
for (int i = 0; i < parametersCount; i++)
{
ref var param = ref signature.Params[i];
@@ -2489,7 +2489,7 @@ namespace FlaxEditor.Surface.Archetypes
{
string.Empty, // Overriden method name
0, // Overriden method parameters count
Array.Empty<byte>(), // Cached function signature data
Utils.GetEmptyArray<byte>(), // Cached function signature data
},
},
new NodeArchetype
@@ -2507,7 +2507,7 @@ namespace FlaxEditor.Surface.Archetypes
string.Empty, // Method name
0, // Method parameters count
false, // Is Pure?
Array.Empty<byte>(), // Cached function signature data
Utils.GetEmptyArray<byte>(), // Cached function signature data
// Default value for parameters (27 entries)
// @formatter:off
@@ -2546,7 +2546,7 @@ namespace FlaxEditor.Surface.Archetypes
Size = new Float2(240, 20),
DefaultValues = new object[]
{
Array.Empty<byte>(), // Function signature data
Utils.GetEmptyArray<byte>(), // Function signature data
},
},
new NodeArchetype
+3 -3
View File
@@ -156,7 +156,7 @@ namespace FlaxEditor.Surface.Archetypes
if (fieldsLength == 0)
{
// Skip allocations if structure is empty
Values[1] = Array.Empty<byte>();
Values[1] = Utils.GetEmptyArray<byte>();
}
else
{
@@ -471,7 +471,7 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
string.Empty, // Typename
Array.Empty<byte>(), // Cached structure layout data
Utils.GetEmptyArray<byte>(), // Cached structure layout data
},
Elements = new[]
{
@@ -591,7 +591,7 @@ namespace FlaxEditor.Surface.Archetypes
DefaultValues = new object[]
{
string.Empty, // Typename
Array.Empty<byte>(), // Cached structure layout data
Utils.GetEmptyArray<byte>(), // Cached structure layout data
},
Elements = new[]
{
+2 -2
View File
@@ -56,8 +56,8 @@ namespace FlaxEditor.Surface
private object Creator(Type type)
{
var ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, Array.Empty<Type>(), null);
return ctor.Invoke(Array.Empty<object>());
var ctor = type.GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, Utils.GetEmptyArray<Type>(), null);
return ctor.Invoke(Utils.GetEmptyArray<object>());
}
}
+1 -1
View File
@@ -1484,7 +1484,7 @@ namespace FlaxEditor.Surface.Elements
protected override void OnAttributesChanged()
{
OnCurrentTypeChanged();
_editor?.UpdateAttributes(this, _attributes ?? Array.Empty<object>(), _defaultValueEditor);
_editor?.UpdateAttributes(this, _attributes ?? Utils.GetEmptyArray<object>(), _defaultValueEditor);
}
/// <inheritdoc />
+2 -2
View File
@@ -91,7 +91,7 @@ namespace FlaxEditor.Surface
}
}
}
return Array.Empty<Attribute>();
return Utils.GetEmptyArray<Attribute>();
}
/// <summary>
@@ -106,7 +106,7 @@ namespace FlaxEditor.Surface
var json = FlaxEngine.Json.JsonSerializer.Serialize(attributes);
return Encoding.Unicode.GetBytes(json);
}
return Array.Empty<byte>();
return Utils.GetEmptyArray<byte>();
}
/// <summary>
+1 -1
View File
@@ -237,7 +237,7 @@ namespace FlaxEditor.Surface
surfaceParameters.Remove(surfaceParameter);
surfaceParameters.Add(surfaceParameter);
}
var attributes = surfaceParameter?.Meta.GetAttributes() ?? Array.Empty<Attribute>();
var attributes = surfaceParameter?.Meta.GetAttributes() ?? FlaxEngine.Utils.GetEmptyArray<Attribute>();
data[i] = new GraphParameterData(null, index++, parameter.Name, parameter.IsPublic, ToType(parameter.ParameterType), attributes, parameter);
i++;
}
@@ -17,7 +17,7 @@ namespace FlaxEditor.Tools.Foliage
private int _selectedInstanceIndex = -1;
/// <summary>
/// The foliage editing gizmo.
/// The foliage painting gizmo.
/// </summary>
public EditFoliageGizmo Gizmo;
@@ -66,6 +66,8 @@ namespace FlaxEditor.Tools.Foliage
base.Init(owner);
Gizmo = new EditFoliageGizmo(owner, this);
SelectionOutline = FlaxEngine.Object.New<EditFoliageSelectionOutline>();
SelectionOutline.GizmoMode = this;
}
/// <inheritdoc />
@@ -82,11 +84,6 @@ namespace FlaxEditor.Tools.Foliage
base.OnActivated();
Owner.Gizmos.Active = Gizmo;
if (SelectionOutline == null)
{
SelectionOutline = FlaxEngine.Object.New<EditFoliageSelectionOutline>();
SelectionOutline.GizmoMode = this;
}
((MainEditorGizmoViewport)Owner).OverrideSelectionOutline(SelectionOutline);
SelectedInstanceIndex = -1;
}
@@ -6,7 +6,7 @@ using FlaxEngine;
namespace FlaxEditor.Tools.Foliage
{
/// <summary>
/// The custom outline for drawing the selected foliage instance.
/// The custom outline for drawing the selected foliage instances outlines.
/// </summary>
/// <seealso cref="FlaxEditor.Gizmo.SelectionOutline" />
[HideInEditor]
+3 -2
View File
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using FlaxEditor.GUI.Tabs;
using FlaxEditor.Modules;
using FlaxEditor.SceneGraph.Actors;
using FlaxEditor.Viewport.Modes;
using FlaxEngine;
using FlaxEngine.GUI;
@@ -213,7 +214,7 @@ namespace FlaxEditor.Tools.Foliage
private void InitSculptMode()
{
var tab = _modes.AddTab(FoliageTypes = new FoliageTypesTab(this, Editor.Windows.EditWin.Viewport.EditFoliageTypesGizmo));
var tab = _modes.AddTab(FoliageTypes = new FoliageTypesTab(this));
tab.Selected += OnTabSelected;
}
@@ -250,7 +251,7 @@ namespace FlaxEditor.Tools.Foliage
switch (_modes.SelectedTabIndex)
{
case 0:
Editor.Windows.EditWin.Viewport.Gizmos.SetActiveMode<FoliageTypesGizmoMode>();
Editor.Windows.EditWin.Viewport.Gizmos.SetActiveMode<NoGizmoMode>();
break;
case 1:
Editor.Windows.EditWin.Viewport.Gizmos.SetActiveMode<PaintFoliageGizmoMode>();
@@ -1,44 +0,0 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEditor.Gizmo;
namespace FlaxEditor.Tools.Foliage
{
/// <summary>
/// Gizmo for editing foliage types.
/// </summary>
public sealed class FoliageTypesGizmo : GizmoBase
{
/// <summary>
/// The parent mode.
/// </summary>
public readonly FoliageTypesGizmoMode GizmoMode;
/// <summary>
/// Initializes a new instance of the <see cref="EditFoliageGizmo"/> class.
/// </summary>
/// <param name="owner">The owner.</param>
/// <param name="mode">The mode.</param>
public FoliageTypesGizmo(IGizmoOwner owner, FoliageTypesGizmoMode mode)
: base(owner)
{
GizmoMode = mode;
}
/// <inheritdoc />
public override void Pick()
{
// Get mouse ray and try to hit foliage instance
var foliage = GizmoMode.SelectedFoliage;
if (!foliage)
return;
var ray = Owner.MouseRay;
if (foliage.Intersects(ref ray, out _, out _, out var instanceIndex))
{
// Select hit instance type
var instance = foliage.GetInstance(instanceIndex);
GizmoMode.SelectedTypeIndex = instance.Type;
}
}
}
}
@@ -1,86 +0,0 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEditor.Gizmo;
using FlaxEditor.SceneGraph.Actors;
using FlaxEditor.Viewport;
using FlaxEditor.Viewport.Modes;
namespace FlaxEditor.Tools.Foliage
{
/// <summary>
/// Foliage types editing mode.
/// </summary>
/// <seealso cref="FlaxEditor.Viewport.Modes.EditorGizmoMode" />
public class FoliageTypesGizmoMode : EditorGizmoMode
{
/// <summary>
/// The foliage types gizmo.
/// </summary>
public FoliageTypesGizmo Gizmo;
/// <summary>
/// The foliage type editing selection outline.
/// </summary>
public FoliageTypesOutline SelectionOutline;
/// <summary>
/// The selected foliage type index.
/// </summary>
public int SelectedTypeIndex
{
get => Editor.Instance.Windows.ToolboxWin.Foliage.SelectedFoliageTypeIndex;
set => Editor.Instance.Windows.ToolboxWin.Foliage.SelectedFoliageTypeIndex = value;
}
/// <summary>
/// Gets the selected foliage actor (see <see cref="Modules.SceneEditingModule"/>).
/// </summary>
public FlaxEngine.Foliage SelectedFoliage
{
get
{
var sceneEditing = Editor.Instance.SceneEditing;
var foliageNode = sceneEditing.SelectionCount == 1 ? sceneEditing.Selection[0] as FoliageNode : null;
return (FlaxEngine.Foliage)foliageNode?.Actor;
}
}
/// <inheritdoc />
public override void Init(IGizmoOwner owner)
{
base.Init(owner);
Gizmo = new FoliageTypesGizmo(owner, this);
}
/// <inheritdoc />
public override void Dispose()
{
FlaxEngine.Object.Destroy(ref SelectionOutline);
base.Dispose();
}
/// <inheritdoc />
public override void OnActivated()
{
base.OnActivated();
Owner.Gizmos.Active = Gizmo;
if (SelectionOutline == null)
{
SelectionOutline = FlaxEngine.Object.New<FoliageTypesOutline>();
SelectionOutline.GizmoMode = this;
}
((MainEditorGizmoViewport)Owner).OverrideSelectionOutline(SelectionOutline);
}
/// <inheritdoc />
public override void OnDeactivated()
{
((MainEditorGizmoViewport)Owner).OverrideSelectionOutline(null);
base.OnDeactivated();
}
}
}
@@ -1,62 +0,0 @@
// Copyright (c) Wojciech Figat. All rights reserved.
using FlaxEditor.Gizmo;
using FlaxEngine;
namespace FlaxEditor.Tools.Foliage
{
/// <summary>
/// The custom outline for drawing the selected foliage type.
/// </summary>
/// <seealso cref="FlaxEditor.Gizmo.SelectionOutline" />
[HideInEditor]
public class FoliageTypesOutline : SelectionOutline
{
/// <summary>
/// The parent mode.
/// </summary>
public FoliageTypesGizmoMode GizmoMode;
/// <inheritdoc />
public override bool CanRender()
{
if (!HasDataReady)
return false;
var foliage = GizmoMode.SelectedFoliage;
if (!foliage)
return false;
var typeIndex = GizmoMode.SelectedTypeIndex;
if (typeIndex < 0 || typeIndex >= foliage.FoliageTypesCount)
return false;
return true;
}
/// <inheritdoc />
public override void Render(GPUContext context, ref RenderContext renderContext, GPUTexture input, GPUTexture output)
{
base.Render(context, ref renderContext, input, output);
// Restore debug option
var foliage = GizmoMode.SelectedFoliage;
if (foliage)
foliage._drawFoliageType = -1;
}
/// <inheritdoc />
protected override void DrawSelectionDepth(GPUContext context, SceneRenderTask task, GPUTexture customDepth)
{
var foliage = GizmoMode.SelectedFoliage;
if (!foliage)
return;
var typeIndex = GizmoMode.SelectedTypeIndex;
if (typeIndex < 0 || typeIndex >= foliage.FoliageTypesCount)
return;
// Draw instances of the given type
foliage._drawFoliageType = typeIndex;
_actors.Add(foliage);
Renderer.DrawSceneDepth(context, task, customDepth, _actors);
}
}
}
@@ -334,8 +334,7 @@ namespace FlaxEditor.Tools.Foliage
/// Initializes a new instance of the <see cref="FoliageTypesTab"/> class.
/// </summary>
/// <param name="tab">The parent tab.</param>
/// <param name="mode">The gizmo mode.</param>
public FoliageTypesTab(FoliageTab tab, FoliageTypesGizmoMode mode)
public FoliageTypesTab(FoliageTab tab)
: base("Foliage Types")
{
Tab = tab;
+7 -16
View File
@@ -1514,14 +1514,9 @@ namespace FlaxEditor.Viewport
Matrix.Multiply(ref v, ref p, out var ivp);
ivp.Invert();
// Create near and far points, with device depth of 1 and 0 respectively
#if REVERSE_Z
var nearPoint = new Vector3(mousePosition, 1.0f);
var farPoint = new Vector3(mousePosition, 0.0f);
#else
var nearPoint = new Vector3(mousePosition, 0.0f);
var farPoint = new Vector3(mousePosition, 1.0f);
#endif
// Create near and far points
var nearPoint = new Vector3(mousePosition, _nearPlane);
var farPoint = new Vector3(mousePosition, _farPlane);
viewport.Unproject(ref nearPoint, ref ivp, out nearPoint);
viewport.Unproject(ref farPoint, ref ivp, out farPoint);
@@ -2089,9 +2084,9 @@ namespace FlaxEditor.Viewport
new ViewModeOptions(ViewMode.Wireframe, "Wireframe", Editor.Instance.Options.Options.Input.Wireframe),
new ViewModeOptions(ViewMode.LightBuffer, "Light Buffer", Editor.Instance.Options.Options.Input.LightBuffer),
new ViewModeOptions(ViewMode.Reflections, "Reflections Buffer", Editor.Instance.Options.Options.Input.ReflectionsBuffer),
new ViewModeOptions(ViewMode.Depth, "Depth Buffer", Editor.Instance.Options.Options.Input.DepthBuffer),
new ViewModeOptions("GBuffer", new[]
{
new ViewModeOptions(ViewMode.Depth, "Depth Buffer", Editor.Instance.Options.Options.Input.DepthBuffer),
new ViewModeOptions(ViewMode.Diffuse, "Diffuse"),
new ViewModeOptions(ViewMode.Metalness, "Metalness"),
new ViewModeOptions(ViewMode.Roughness, "Roughness"),
@@ -2107,13 +2102,9 @@ namespace FlaxEditor.Viewport
new ViewModeOptions(ViewMode.LightmapUVsDensity, "Lightmap UVs Density", Editor.Instance.Options.Options.Input.LightmapUVDensity),
new ViewModeOptions(ViewMode.VertexColors, "Vertex Colors", Editor.Instance.Options.Options.Input.VertexColors),
new ViewModeOptions(ViewMode.PhysicsColliders, "Physics Colliders", Editor.Instance.Options.Options.Input.PhysicsColliders),
new ViewModeOptions("Optimization", new[]
{
new ViewModeOptions(ViewMode.LODPreview, "LOD Preview", Editor.Instance.Options.Options.Input.LODPreview),
new ViewModeOptions(ViewMode.MaterialComplexity, "Material Complexity", Editor.Instance.Options.Options.Input.MaterialComplexity),
new ViewModeOptions(ViewMode.QuadOverdraw, "Quad Overdraw", Editor.Instance.Options.Options.Input.QuadOverdraw),
new ViewModeOptions(ViewMode.GlobalSDFOverdraw, "Global SDF Overdraw"),
}),
new ViewModeOptions(ViewMode.LODPreview, "LOD Preview", Editor.Instance.Options.Options.Input.LODPreview),
new ViewModeOptions(ViewMode.MaterialComplexity, "Material Complexity", Editor.Instance.Options.Options.Input.MaterialComplexity),
new ViewModeOptions(ViewMode.QuadOverdraw, "Quad Overdraw", Editor.Instance.Options.Options.Input.QuadOverdraw),
new ViewModeOptions(ViewMode.GlobalSDF, "Global SDF", Editor.Instance.Options.Options.Input.GloablSDF),
new ViewModeOptions(ViewMode.GlobalSurfaceAtlas, "Global Surface Atlas", Editor.Instance.Options.Options.Input.GlobalSurfaceAtlas),
new ViewModeOptions(ViewMode.GlobalIllumination, "Global Illumination", Editor.Instance.Options.Options.Input.GlobalIllumination),
@@ -179,17 +179,12 @@ namespace FlaxEditor.Viewport
public Tools.Terrain.EditTerrainGizmoMode EditTerrainGizmo;
/// <summary>
/// The edit foliage types gizmo.
/// </summary>
public Tools.Foliage.FoliageTypesGizmoMode EditFoliageTypesGizmo;
/// <summary>
/// The paint foliage instances gizmo.
/// The paint foliage gizmo.
/// </summary>
public Tools.Foliage.PaintFoliageGizmoMode PaintFoliageGizmo;
/// <summary>
/// The edit foliage instances gizmo.
/// The edit foliage gizmo.
/// </summary>
public Tools.Foliage.EditFoliageGizmoMode EditFoliageGizmo;
@@ -281,7 +276,6 @@ namespace FlaxEditor.Viewport
Gizmos.AddMode(SculptTerrainGizmo = new Tools.Terrain.SculptTerrainGizmoMode());
Gizmos.AddMode(PaintTerrainGizmo = new Tools.Terrain.PaintTerrainGizmoMode());
Gizmos.AddMode(EditTerrainGizmo = new Tools.Terrain.EditTerrainGizmoMode());
Gizmos.AddMode(EditFoliageTypesGizmo = new Tools.Foliage.FoliageTypesGizmoMode());
Gizmos.AddMode(PaintFoliageGizmo = new Tools.Foliage.PaintFoliageGizmoMode());
Gizmos.AddMode(EditFoliageGizmo = new Tools.Foliage.EditFoliageGizmoMode());
@@ -349,12 +343,10 @@ namespace FlaxEditor.Viewport
/// <param name="customSelectionOutline">The custom selection outline or null if use default one.</param>
public void OverrideSelectionOutline(SelectionOutline customSelectionOutline)
{
if (Task == null)
return;
if (_customSelectionOutline != null)
{
Task.RemoveCustomPostFx(_customSelectionOutline);
Object.Destroy(ref _customSelectionOutline);
Task.AddCustomPostFx(customSelectionOutline ? customSelectionOutline : SelectionOutline);
}
else if (customSelectionOutline != null)
@@ -538,7 +530,7 @@ namespace FlaxEditor.Viewport
}
/// <summary>
/// Toggles view mode on/off.
/// Toggles game view view mode on or off.
/// </summary>
public void ToggleGameView()
{
@@ -555,9 +547,9 @@ namespace FlaxEditor.Viewport
// Set flags & values
Task.ViewFlags = _gameViewActive ? _preGameViewFlags : ViewFlags.DefaultGame;
Task.ViewMode = _gameViewActive ? _preGameViewViewMode : ViewMode.Default;
ShowFpsCounter = _gameViewActive && _gameViewWasFpsCounterShown;
ShowNavigation = _gameViewActive && _gameViewWasNavigationShown;
Grid.Enabled = _gameViewActive && _gameViewWasGridShown;
ShowFpsCounter = _gameViewActive ? _gameViewWasFpsCounterShown : false;
ShowNavigation = _gameViewActive ? _gameViewWasNavigationShown : false;
Grid.Enabled = _gameViewActive ? _gameViewWasGridShown : false;
_gameViewActive = !_gameViewActive;
@@ -738,20 +730,6 @@ namespace FlaxEditor.Viewport
base.OnLeftMouseButtonUp();
}
/// <inheritdoc />
public override bool OnKeyDown(KeyboardKeys key)
{
if (base.OnKeyDown(key))
return true;
if (key == KeyboardKeys.Escape)
{
_editor.SceneEditing.Deselect();
}
return false;
}
/// <inheritdoc />
public override bool OnMouseUp(Float2 location, MouseButton button)
{
@@ -865,8 +843,8 @@ namespace FlaxEditor.Viewport
if (_task != null)
{
// Release if task is not used to save screenshot for project icon
ReleaseTaskResources();
Object.Destroy(ref _task);
ReleaseResources();
}
base.OnDestroy();
@@ -882,7 +860,6 @@ namespace FlaxEditor.Viewport
_savedTask = _task;
_savedBackBuffer = _backBuffer;
ReleaseTaskResources();
_task = null;
_backBuffer = null;
}
@@ -893,20 +870,20 @@ namespace FlaxEditor.Viewport
{
_savedTask.Enabled = false;
Object.Destroy(_savedTask);
ReleaseTaskResources();
ReleaseResources();
_savedTask = null;
}
Object.Destroy(ref _savedBackBuffer);
}
private void ReleaseTaskResources()
private void ReleaseResources()
{
if (_task)
if (Task)
{
_task.RemoveCustomPostFx(SelectionOutline);
_task.RemoveCustomPostFx(EditorPrimitives);
_task.RemoveCustomPostFx(_editorSpritesRenderer);
_task.RemoveCustomPostFx(_customSelectionOutline);
Task.RemoveCustomPostFx(SelectionOutline);
Task.RemoveCustomPostFx(EditorPrimitives);
Task.RemoveCustomPostFx(_editorSpritesRenderer);
Task.RemoveCustomPostFx(_customSelectionOutline);
}
Object.Destroy(ref SelectionOutline);
Object.Destroy(ref EditorPrimitives);
+1 -1
View File
@@ -136,9 +136,9 @@ namespace FlaxEditor.Windows
{
"Used third party software:",
"",
"Mono Project - www.mono-project.com",
#if USE_NETCORE
".NET - www.dotnet.microsoft.com",
"Mono Project - www.mono-project.com",
#endif
#if PLATFORM_SDL
"Simple DirectMedia Layer - www.libsdl.org",
@@ -233,7 +233,7 @@ namespace FlaxEditor.Windows.Assets
var materialInstance = proxy.Window?.Asset;
if (materialInstance == null)
{
layout.Label("No parameters", TextAlignment.Center);
layout.Label("No parameters");
return;
}
if (!materialInstance.IsLoaded || (materialInstance.BaseMaterial && !materialInstance.BaseMaterial.IsLoaded))
@@ -246,10 +246,7 @@ namespace FlaxEditor.Windows.Assets
base.Initialize(layout);
if (parameters.Length == 0)
{
layout.Label("No parameters", TextAlignment.Center);
return;
}
var parametersGroup = SurfaceUtils.InitGraphParametersGroup(layout);
var settingButton = parametersGroup.AddSettingsButton();
@@ -502,7 +502,7 @@ namespace FlaxEditor.Windows.Assets
{
Name = $"{name} (in {member.DeclaringType.Name})",
TooltipText = Editor.Instance.CodeDocs.GetTooltip(member),
Tag = new object[] { name, parameters.Length, Array.Empty<byte>() },
Tag = new object[] { name, parameters.Length, Utils.GetEmptyArray<byte>() },
// Do some basic sorting based on if the method is defined directly in the script base class
SortScore = member.DeclaringType == member.Type.ReflectedType ? 1 : 0,
};
+2 -1
View File
@@ -821,7 +821,8 @@ namespace FlaxEditor.Windows
{
base.Draw();
if (Camera.MainCamera == null)
var mainRenderTask = MainRenderTask.Instance;
if (Camera.MainCamera == null && (mainRenderTask == null || !mainRenderTask.IsCustomRendering))
{
var style = Style.Current;
Render2D.DrawText(style.FontLarge, "No camera", new Rectangle(Float2.Zero, Size), style.ForegroundDisabled, TextAlignment.Center, TextAlignment.Center);
+1 -1
View File
@@ -49,7 +49,7 @@ namespace FlaxEditor.Windows.Profiler
{
Title = "Draw (GPU)",
AnchorPreset = AnchorPresets.HorizontalStretchTop,
Offsets = new Margin(0, 0, _drawTimeCPU.Height + 2, SingleChart.DefaultHeight),
Offsets = new Margin(0, 0, _drawTimeCPU.Height + 2, 0),
FormatSample = v => (Mathf.RoundToInt(v * 10.0f) / 10.0f) + " ms",
Parent = mainPanel,
};
+4 -4
View File
@@ -559,7 +559,7 @@ namespace FlaxEngine
/// </summary>
public LinearCurve()
{
Keyframes = Array.Empty<Keyframe>();
Keyframes = Utils.GetEmptyArray<Keyframe>();
}
/// <summary>
@@ -655,7 +655,7 @@ namespace FlaxEngine
if (end - start <= Mathf.Epsilon)
{
// Erase the curve
Keyframes = Array.Empty<Keyframe>();
Keyframes = Utils.GetEmptyArray<Keyframe>();
return;
}
@@ -866,7 +866,7 @@ namespace FlaxEngine
/// </summary>
public BezierCurve()
{
Keyframes = Array.Empty<Keyframe>();
Keyframes = Utils.GetEmptyArray<Keyframe>();
}
/// <summary>
@@ -970,7 +970,7 @@ namespace FlaxEngine
if (end - start <= Mathf.Epsilon)
{
// Erase the curve
Keyframes = Array.Empty<Keyframe>();
Keyframes = Utils.GetEmptyArray<Keyframe>();
return;
}
@@ -79,6 +79,13 @@ DEFINE_INTERNAL_CALL(AnimGraphImpulse*) AnimGraphInternal_GetOutputImpulseData(I
#endif
void AnimGraphExecutor::initRuntime()
{
ADD_INTERNAL_CALL("FlaxEngine.AnimationGraph::Internal_HasConnection", &AnimGraphInternal_HasConnection);
ADD_INTERNAL_CALL("FlaxEngine.AnimationGraph::Internal_GetInputValue", &AnimGraphInternal_GetInputValue);
ADD_INTERNAL_CALL("FlaxEngine.AnimationGraph::Internal_GetOutputImpulseData", &AnimGraphInternal_GetOutputImpulseData);
}
void AnimGraphExecutor::ProcessGroupCustom(Box* boxBase, Node* nodeBase, Value& value)
{
#if USE_CSHARP
@@ -813,6 +813,11 @@ private:
static ThreadLocal<AnimGraphContext*> Context;
public:
/// <summary>
/// Initializes the managed runtime calls.
/// </summary>
static void initRuntime();
/// <summary>
/// Initializes a new instance of the <see cref="AnimGraphExecutor"/> class.
/// </summary>
-10
View File
@@ -430,9 +430,6 @@ void Asset::Reload()
ScopeLock lock(Locker);
// Cancel any still-running loading task (e.g. if WaitForLoaded timed out)
Platform::AtomicStore(&_loadingTask, 0);
if (IsLoaded())
{
// Unload current data
@@ -615,13 +612,6 @@ bool Asset::onLoad(LoadAssetTask* task)
Locker.Lock();
// Re-check after acquiring lock (loading task may have been cleared by Reload, or replaced by a new task)
if (Platform::AtomicRead(&_loadingTask) == 0)
{
Locker.Unlock();
return true;
}
// Load asset
LoadResult result;
#if USE_EDITOR
+2 -2
View File
@@ -101,9 +101,9 @@ bool Material::CanUseLightmap() const
return _materialShader && _materialShader->CanUseLightmap();
}
bool Material::CanUseInstancing(const RenderContext& renderContext, InstancingHandler& handler) const
bool Material::CanUseInstancing(InstancingHandler& handler) const
{
return _materialShader && _materialShader->CanUseInstancing(renderContext, handler);
return _materialShader && _materialShader->CanUseInstancing(handler);
}
void Material::Bind(BindParameters& params)
+1 -1
View File
@@ -48,7 +48,7 @@ public:
bool IsReady() const override;
DrawPass GetDrawModes() const override;
bool CanUseLightmap() const override;
bool CanUseInstancing(const RenderContext& renderContext, InstancingHandler& handler) const override;
bool CanUseInstancing(InstancingHandler& handler) const override;
void Bind(BindParameters& params) override;
// [ShaderAssetBase]
@@ -168,9 +168,9 @@ bool MaterialInstance::CanUseLightmap() const
return _baseMaterial && _baseMaterial->CanUseLightmap();
}
bool MaterialInstance::CanUseInstancing(const RenderContext& renderContext, InstancingHandler& handler) const
bool MaterialInstance::CanUseInstancing(InstancingHandler& handler) const
{
return _baseMaterial && _baseMaterial->CanUseInstancing(renderContext, handler);
return _baseMaterial && _baseMaterial->CanUseInstancing(handler);
}
void MaterialInstance::Bind(BindParameters& params)
@@ -53,7 +53,7 @@ public:
bool IsReady() const override;
DrawPass GetDrawModes() const override;
bool CanUseLightmap() const override;
bool CanUseInstancing(const RenderContext& renderContext, InstancingHandler& handler) const override;
bool CanUseInstancing(InstancingHandler& handler) const override;
void Bind(BindParameters& params) override;
protected:
-11
View File
@@ -27,17 +27,6 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API SceneReference
{
return ID != other.ID;
}
FORCE_INLINE SceneReference& operator=(const Guid& id)
{
ID = id;
return *this;
}
FORCE_INLINE operator Guid() const
{
return ID;
}
};
template<>
@@ -9,7 +9,6 @@
#include "Engine/Level/Types.h"
#include "Engine/Debug/Exceptions/JsonParseException.h"
#include "Engine/Profiler/ProfilerCPU.h"
#include "Engine/Profiler/ProfilerMemory.h"
#if USE_EDITOR
#include "Engine/Core/Collections/HashSet.h"
#include "Engine/Core/Collections/Dictionary.h"
@@ -21,66 +20,17 @@ bool JsonStorageProxy::IsValidExtension(const StringView& extension)
return extension == DEFAULT_SCENE_EXTENSION || extension == DEFAULT_PREFAB_EXTENSION || extension == DEFAULT_JSON_EXTENSION;
}
StringAnsiView ParseJsonString(const StringAnsiView& json, int32 start)
{
while (start < json.Length() && json[start] != '\"')
start++;
int32 end = start + 1;
while (end < json.Length() && json[end] != '\"')
end++;
return json.Substring(start + 1, end - start - 1);
}
bool JsonStorageProxy::GetAssetInfo(const StringView& path, Guid& resultId, String& resultDataTypeName)
{
PROFILE_CPU();
PROFILE_MEM(Content);
ZoneText(*path, path.Length());
// Read the first part of the file to get asset metadata (ID and TypeName)
auto file = File::Open(path, FileMode::OpenExisting, FileAccess::Read, FileShare::All);
if (!file)
return false;
Array<byte> fileData;
fileData.Resize(256);
uint32 read = 0;
file->Read(fileData.Get(), fileData.Count(), &read);
Delete(file);
file = nullptr;
if (read != 0)
{
// Naive Json parsing to get ID and TypeName without full parsing
StringAnsiView json((const char*)fileData.Get(), read);
StringAnsiView idStart("\"ID\": ");
StringAnsiView typenameStart("\"TypeName\": ");
bool hasOneOfThem = false;
for (int32 i = 0; i < json.Length() - 7; i++)
{
if (json.Substring(i).StartsWith(idStart))
{
StringAnsiView value = ParseJsonString(json, i + idStart.Length());
if (Guid::Parse(value, resultId))
continue;
if (hasOneOfThem)
return true;
hasOneOfThem = true;
i += value.Length() + idStart.Length() + 2;
}
if (json.Substring(i).StartsWith(typenameStart))
{
StringAnsiView value = ParseJsonString(json, i + typenameStart.Length());
resultDataTypeName = String(value);
if (hasOneOfThem)
return true;
hasOneOfThem = true;
i += value.Length() + typenameStart.Length() + 2;
}
}
}
// TODO: we could just open file and start reading until we find 'ID:..' without parsing whole file - could be much more faster
// Load file
Array<byte> fileData;
if (File::ReadAllBytes(path, fileData))
{
return false;
}
// Parse data
rapidjson_flax::Document document;
@@ -139,8 +89,11 @@ void FindObjectIds(const rapidjson_flax::Value& obj, const rapidjson_flax::Docum
}
}
#endif
bool JsonStorageProxy::ChangeId(const StringView& path, const Guid& newId)
{
#if USE_EDITOR
PROFILE_CPU();
// Load file
@@ -187,6 +140,8 @@ bool JsonStorageProxy::ChangeId(const StringView& path, const Guid& newId)
return true;
return false;
}
#else
LOG(Warning, "Editing cooked content is invalid.");
return true;
#endif
}
@@ -30,7 +30,6 @@ public:
/// <returns>True if found any asset, otherwise false.</returns>
static bool GetAssetInfo(const StringView& path, Guid& resultId, String& resultDataTypeName);
#if USE_EDITOR
/// <summary>
/// Changes asset ID.
/// </summary>
@@ -38,5 +37,4 @@ public:
/// <param name="newId">Asset ID to set</param>
/// <returns>True if found any asset, otherwise false.</returns>
static bool ChangeId(const StringView& path, const Guid& newId);
#endif
};
@@ -113,8 +113,6 @@ CreateAssetContext::CreateAssetContext(const StringView& inputPath, const String
CreateAssetResult CreateAssetContext::Run(const CreateAssetFunction& callback)
{
PROFILE_CPU();
PROFILE_MEM(Content);
ASSERT(callback.IsBinded());
// Call action
@@ -209,9 +207,6 @@ void CreateAssetContext::AddMeta(JsonWriter& writer) const
void CreateAssetContext::ApplyChanges()
{
PROFILE_CPU();
PROFILE_MEM(Content);
// Get access
auto storage = ContentStorageManager::TryGetStorage(TargetAssetPath);
if (storage && storage->IsLoaded())
@@ -279,8 +274,6 @@ bool AssetsImportingManager::Create(const String& tag, const StringView& outputP
bool AssetsImportingManager::Import(const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg)
{
PROFILE_CPU();
PROFILE_MEM(Content);
LOG(Info, "Importing file '{0}' to '{1}'...", inputPath, outputPath);
// Check if input file exists
@@ -354,7 +347,6 @@ String AssetsImportingManager::GetImportPath(const String& path)
bool AssetsImportingManager::Create(const Function<CreateAssetResult(CreateAssetContext&)>& callback, const StringView& inputPath, const StringView& outputPath, Guid& assetId, void* arg)
{
PROFILE_CPU();
PROFILE_MEM(Content);
ZoneText(*outputPath, outputPath.Length());
const auto startTime = Platform::GetTimeSeconds();
@@ -365,7 +365,7 @@ namespace FlaxEngine.Collections
public T[] ToArray()
{
if (Count == 0)
return Array.Empty<T>();
return Utils.GetEmptyArray<T>();
var result = new T[Count];
if (_backItem > _frontItem)

Some files were not shown because too many files have changed in this diff Show More