Files
sbox-public/engine/Sandbox.Engine/Scene/Components/Render/Decal.Upgrade.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

36 lines
787 B
C#

using System.Text.Json;
using System.Text.Json.Nodes;
namespace Sandbox;
public partial class Decal
{
public override int ComponentVersion => 3;
[Expose, JsonUpgrader( typeof( Decal ), 2 )]
public static void Upgrader_v2( JsonObject json )
{
if ( !json.ContainsKey( "ColorTint" ) ) return;
try
{
var color32 = json["ColorTint"].Deserialize<Color32>();
json["ColorTint"] = JsonSerializer.SerializeToNode( color32.ToColor() );
}
catch { }
}
[Expose, JsonUpgrader( typeof( Decal ), 3 )]
public static void Upgrader_v3( JsonObject json )
{
if ( !json.ContainsKey( "ColorTint" ) ) return;
try
{
var color = json["ColorTint"].Deserialize<Color>();
json["ColorTint"] = JsonSerializer.SerializeToNode( (ParticleGradient)color );
}
catch { }
}
}