Author Topic: Reimport sometimes forgets output options  (Read 930 times)

Sometimes, and I can't pin it down, the substance graph instances lose their output settings on reimport. When reimporting you check for outputs by id, so it may be that the id is being changed when you reexport the substance or something. To remedy this, i've done a lookup by output name as well or id.

In SubstanceFactory.cpp, replace ReimportData with:
struct ReimportData
{
   FString PackageURL;
   UMaterial* OwnedMaterialReferencee;
   TMap<uint32, USubstanceImageInput*> ImageSources;
   TArray<MaterialParameterSet> ReferencingMaterials;
   TArray<MaterialInstanceParameterSet> ReferencingMaterialInstances;
   TArray<uint32> EnabledOutputUIDs;
   TArray<FName> EnabledOutputNames;
   SubstanceAir::shared_ptr<SubstanceAir::Preset> PreviousPresetData;

   ReimportData(const FString& packageURL, UMaterial* owningMaterial, SubstanceAir::shared_ptr<SubstanceAir::Preset> preset,
                TArray<MaterialParameterSet>& referencingMaterials, TArray<MaterialInstanceParameterSet>& referencingMaterialInstances, TMap<uint32, USubstanceImageInput*>& imageSources, TArray<uint32>& enabledOutputUIDs, TArray<FName>& enabledOutputNames)
   {
      PackageURL = packageURL;
      ImageSources = imageSources;
      PreviousPresetData = preset;
      EnabledOutputUIDs = enabledOutputUIDs;
      ReferencingMaterials = referencingMaterials;
      ReferencingMaterialInstances = referencingMaterialInstances;
      OwnedMaterialReferencee = owningMaterial;
      EnabledOutputNames = enabledOutputNames;
   }
};

...and line 429 with:
if (!OutputItr->mUserData && (GrItr.EnabledOutputUIDs.Contains(OutputItr->mDesc.mUid) || GrItr.EnabledOutputNames.Contains(FName(OutputItr->mDesc.mLabel.c_str()))))

... and lines 663 to 675 with:
      //Array of all of the enabled output UIDs
      TArray<uint32> EnabledOutputs;
      TArray<FName> EnabledOutputNames;

      //Save the enabled state of all of the outputs
      for (const auto& OutputItr : GraphItr->Instance->getOutputs())
      {
         if (OutputItr->mEnabled && OutputItr->mUserData)
         {
            EnabledOutputs.AddUnique(OutputItr->mDesc.mUid);
            EnabledOutputNames.AddUnique(FName(OutputItr->mDesc.mLabel.c_str()));
         }
      }