Add required options for material instance importing.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -316,6 +317,20 @@ namespace FlaxEditor.Content.Import
|
||||
[EditorOrder(400), DefaultValue(true)]
|
||||
public bool ImportMaterials { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// If checked, materials will be imported as instances of a base material.
|
||||
/// </summary>
|
||||
[EditorDisplay("Materials"), VisibleIf(nameof(ImportMaterials))]
|
||||
[EditorOrder(405), DefaultValue(false)]
|
||||
public bool ImportMaterialsAsInstances = false;
|
||||
|
||||
/// <summary>
|
||||
/// The material to import the model's materials as an instance of.
|
||||
/// </summary>
|
||||
[EditorDisplay("Materials"), VisibleIf(nameof(ImportMaterialsAsInstances))]
|
||||
[EditorOrder(406)]
|
||||
public Material InstanceToImportAs = null; // TODO: only show if BOTH ImportMaterials and ImportMaterialsAsInstances are true.
|
||||
|
||||
/// <summary>
|
||||
/// If checked, the importer will import texture files used by the model and any embedded texture resources.
|
||||
/// </summary>
|
||||
@@ -406,6 +421,8 @@ namespace FlaxEditor.Content.Import
|
||||
|
||||
// Misc
|
||||
public byte ImportMaterials;
|
||||
public byte ImportMaterialsAsInstances;
|
||||
public Guid InstanceToImportAs;
|
||||
public byte ImportTextures;
|
||||
public byte RestoreMaterialsOnReimport;
|
||||
|
||||
@@ -454,6 +471,8 @@ namespace FlaxEditor.Content.Import
|
||||
LODCount = LODCount,
|
||||
TriangleReduction = TriangleReduction,
|
||||
ImportMaterials = (byte)(ImportMaterials ? 1 : 0),
|
||||
ImportMaterialsAsInstances = (byte)(ImportMaterialsAsInstances ? 1 : 0),
|
||||
InstanceToImportAs = InstanceToImportAs.ID,
|
||||
ImportTextures = (byte)(ImportTextures ? 1 : 0),
|
||||
RestoreMaterialsOnReimport = (byte)(RestoreMaterialsOnReimport ? 1 : 0),
|
||||
GenerateSDF = (byte)(GenerateSDF ? 1 : 0),
|
||||
@@ -496,6 +515,8 @@ namespace FlaxEditor.Content.Import
|
||||
LODCount = options.LODCount;
|
||||
TriangleReduction = options.TriangleReduction;
|
||||
ImportMaterials = options.ImportMaterials != 0;
|
||||
ImportMaterialsAsInstances = options.ImportMaterialsAsInstances != 0;
|
||||
InstanceToImportAs = FlaxEngine.Content.Load<Material>(options.InstanceToImportAs);
|
||||
ImportTextures = options.ImportTextures != 0;
|
||||
RestoreMaterialsOnReimport = options.RestoreMaterialsOnReimport != 0;
|
||||
GenerateSDF = options.GenerateSDF != 0;
|
||||
|
||||
@@ -195,6 +195,8 @@ struct InternalModelOptions
|
||||
|
||||
// Misc
|
||||
byte ImportMaterials;
|
||||
byte ImportMaterialsAsInstances;
|
||||
Guid InstanceToImportAs;
|
||||
byte ImportTextures;
|
||||
byte RestoreMaterialsOnReimport;
|
||||
|
||||
@@ -240,6 +242,8 @@ struct InternalModelOptions
|
||||
to->LODCount = from->LODCount;
|
||||
to->TriangleReduction = from->TriangleReduction;
|
||||
to->ImportMaterials = from->ImportMaterials;
|
||||
to->ImportMaterialsAsInstances = from->ImportMaterialsAsInstances;
|
||||
to->InstanceToImportAs = from->InstanceToImportAs;
|
||||
to->ImportTextures = from->ImportTextures;
|
||||
to->RestoreMaterialsOnReimport = from->RestoreMaterialsOnReimport;
|
||||
to->GenerateSDF = from->GenerateSDF;
|
||||
@@ -282,6 +286,8 @@ struct InternalModelOptions
|
||||
to->LODCount = from->LODCount;
|
||||
to->TriangleReduction = from->TriangleReduction;
|
||||
to->ImportMaterials = from->ImportMaterials;
|
||||
to->ImportMaterialsAsInstances = from->ImportMaterialsAsInstances;
|
||||
to->InstanceToImportAs = from->InstanceToImportAs;
|
||||
to->ImportTextures = from->ImportTextures;
|
||||
to->RestoreMaterialsOnReimport = from->RestoreMaterialsOnReimport;
|
||||
to->GenerateSDF = from->GenerateSDF;
|
||||
|
||||
@@ -61,6 +61,8 @@ void ModelTool::Options::Serialize(SerializeStream& stream, const void* otherObj
|
||||
SERIALIZE(LODCount);
|
||||
SERIALIZE(TriangleReduction);
|
||||
SERIALIZE(ImportMaterials);
|
||||
SERIALIZE(ImportMaterialsAsInstances);
|
||||
SERIALIZE(InstanceToImportAs);
|
||||
SERIALIZE(ImportTextures);
|
||||
SERIALIZE(RestoreMaterialsOnReimport);
|
||||
SERIALIZE(GenerateSDF);
|
||||
@@ -102,6 +104,8 @@ void ModelTool::Options::Deserialize(DeserializeStream& stream, ISerializeModifi
|
||||
DESERIALIZE(LODCount);
|
||||
DESERIALIZE(TriangleReduction);
|
||||
DESERIALIZE(ImportMaterials);
|
||||
DESERIALIZE(ImportMaterialsAsInstances);
|
||||
DESERIALIZE(InstanceToImportAs);
|
||||
DESERIALIZE(ImportTextures);
|
||||
DESERIALIZE(RestoreMaterialsOnReimport);
|
||||
DESERIALIZE(GenerateSDF);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Engine/Graphics/Models/ModelData.h"
|
||||
#include "Engine/Graphics/Models/SkeletonData.h"
|
||||
#include "Engine/Animations/AnimationData.h"
|
||||
#include <Engine/Content/Assets/Material.h>
|
||||
|
||||
class JsonWriter;
|
||||
|
||||
@@ -247,6 +248,8 @@ public:
|
||||
|
||||
// Materials
|
||||
bool ImportMaterials = true;
|
||||
bool ImportMaterialsAsInstances = false;
|
||||
Guid InstanceToImportAs;
|
||||
bool ImportTextures = true;
|
||||
bool RestoreMaterialsOnReimport = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user