User Tools

Site Tools


besiege:modding:serialization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
besiege:modding:serialization [2018/06/27 14:40]
spaar [Manual validation logic]
besiege:modding:serialization [2018/06/27 14:41] (current)
spaar [TransformValues]
Line 103: Line 103:
 Then, as custom validation logic, you can set default values on the object and ultimately call ''​Check''​ on it. An example is below: Then, as custom validation logic, you can set default values on the object and ultimately call ''​Check''​ on it. An example is below:
  
-```c# protected override bool Validate(string elemName) { if (!base.Validate(elemName)) return false;+<code csharp>​ 
 +protected override bool Validate(string elemName) { 
 +    ​if (!base.Validate(elemName)) return false;
  
-<​code>​ +    ​SomeTransformValue 
-SomeTransformValue +        .SetPositionDefault(new Vector3(0f, 0f, 0f)) 
-    .SetPositionDefault(new Vector3(0f, 0f, 0f)) +        .SetRotationDefault(new Vector3(0f, 0f, 0f)) 
-    .SetRotationDefault(new Vector3(0f, 0f, 0f)) +        .SetScaleDefault(new Vector3(0f, 0f, 0f));
-    .SetScaleDefault(new Vector3(0f, 0f, 0f));+
  
-if (!SomeTransformValue.Check("​SomeTransformValue"​)) return false;+    ​if (!SomeTransformValue.Check("​SomeTransformValue"​)) return false; 
 +}
 </​code>​ </​code>​
- 
-} ``` 
  
 It is possible to specify any combination of defaults, e.g. one for rotation and scale but none for position. The values without default will be treated as required to be specified by the user. It is possible to specify any combination of defaults, e.g. one for rotation and scale but none for position. The values without default will be treated as required to be specified by the user.
besiege/modding/serialization.txt · Last modified: 2018/06/27 14:41 by spaar