瀏覽代碼

Merge pull request #9624 from Popov72/fix-nme-serialize-mode

NME: Fix serialization of target property in node blocks
sebavan 4 年之前
父節點
當前提交
bd461812cd

+ 2 - 3
nodeEditor/src/diagram/properties/genericNodePropertyComponent.tsx

@@ -57,9 +57,8 @@ export class GeneralPropertyTabComponent extends React.Component<IPropertyCompon
                             }} />
                     }
                     {
-                        (this.props.block.target === NodeMaterialBlockTargets.Neutral || (this.props.block as any)._modifiedTarget) &&
+                        (this.props.block._originalTargetIsNeutral) &&
                         <OptionsLineComponent label="Target" options={targetOptions} target={this.props.block} propertyName="target" onSelect={(value: any) => {
-                            (this.props.block as any)._modifiedTarget = true;
                             this.forceUpdate();
 
                             this.props.globalState.onUpdateRequiredObservable.notifyObservers();
@@ -67,7 +66,7 @@ export class GeneralPropertyTabComponent extends React.Component<IPropertyCompon
                         }} />
                     }
                     {
-                        (this.props.block.target !== NodeMaterialBlockTargets.Neutral && !(this.props.block as any)._modifiedTarget) &&
+                        (!this.props.block._originalTargetIsNeutral) &&
                         <TextLineComponent label="Type" value={NodeMaterialBlockTargets[this.props.block.target]} />
                     }
                     <TextLineComponent label="Type" value={this.props.block.getClassName()} />

+ 6 - 0
src/Materials/Node/nodeMaterialBlock.ts

@@ -40,6 +40,9 @@ export class NodeMaterialBlock {
     /** @hidden */
     public _preparationId: number;
 
+    /** @hidden */
+    public readonly _originalTargetIsNeutral: boolean;
+
     /**
      * Gets the name of the block
      */
@@ -172,6 +175,7 @@ export class NodeMaterialBlock {
     public constructor(name: string, target = NodeMaterialBlockTargets.Vertex, isFinalMerger = false, isInput = false) {
 
         this._target = target;
+        this._originalTargetIsNeutral = target === NodeMaterialBlockTargets.Neutral;
         this._isFinalMerger = isFinalMerger;
         this._isInput = isInput;
         this._name = name;
@@ -716,6 +720,7 @@ export class NodeMaterialBlock {
         serializationObject.comments = this.comments;
         serializationObject.visibleInInspector = this.visibleInInspector;
         serializationObject.visibleOnFrame = this.visibleOnFrame;
+        serializationObject.target = this.target;
 
         serializationObject.inputs = [];
         serializationObject.outputs = [];
@@ -737,6 +742,7 @@ export class NodeMaterialBlock {
         this.comments = serializationObject.comments;
         this.visibleInInspector = !!serializationObject.visibleInInspector;
         this.visibleOnFrame = !!serializationObject.visibleOnFrame;
+        this._target = serializationObject.target ?? this.target;
         this._deserializePortDisplayNamesAndExposedOnFrame(serializationObject);
     }