-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathTest.cs
69 lines (61 loc) · 2.64 KB
/
Test.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using GDExtension.Wrappers;
using Godot;
public partial class Test : Node
{
/// <summary>
/// You may export the wrapper type and assign the reference
/// from the editor. Note that you need to attach the wrapper
/// script to the GDExtension Node instance.
/// </summary>
[Export] private GDCubismUserModel _gdCubismUserModel;
/// <summary>
/// Developers may wrap around an exported resource using
/// the wrapper. Ensure the type is a match.
/// </summary>
/// <remarks>
/// This hint should filter the inspector options.
/// </remarks>
[Export(PropertyHint.ResourceType, nameof(GDCubismParameter))] private Resource _gdCubismParameter;
public override void _Ready()
{
// All wrapped GDExtension types should be created
// via the Instantiate() method
using var summator = Summator.Instantiate();
// Demonstrating method calls
GD.Print(summator.GetTotal());
summator.Add(20);
GD.Print(summator.GetTotal());
summator.Reset();
GD.Print(summator.GetTotal());
var gdCubismParameterInstance = GDCubismParameter.Instantiate();
GD.Print(gdCubismParameterInstance.DefaultValue);
gdCubismParameterInstance.DefaultValue = 20;
GD.Print(gdCubismParameterInstance.DefaultValue);
gdCubismParameterInstance.DefaultValue = -20;
GD.Print(gdCubismParameterInstance.DefaultValue);
// This wraps around an existing resource type.
// The developer should ensure the supplied Godot
// matches the underlying GDExtension type.
var gdCubismParameterWrapper = GDCubismParameter.Bind(_gdCubismParameter);
GD.Print(gdCubismParameterWrapper.DefaultValue);
gdCubismParameterWrapper.DefaultValue = 20;
GD.Print(gdCubismParameterWrapper.DefaultValue);
gdCubismParameterWrapper.DefaultValue = -20;
GD.Print(gdCubismParameterWrapper.DefaultValue);
// Accessing the properties and methods from
// an exported wrapper type. The developer
// has to attach the wrapper script to that
// GDExtension node instance in order for it
// to work.
GD.Print(_gdCubismUserModel.AutoScale);
_gdCubismUserModel.AutoScale = true;
GD.Print(_gdCubismUserModel.AutoScale);
_gdCubismUserModel.AutoScale = false;
GD.Print(_gdCubismUserModel.AutoScale);
_gdCubismUserModel.Free();
_gdCubismUserModel = null;
var terrain3DData = Terrain3DData.Instantiate();
terrain3DData.ControlMaps = [new Image()];
GD.Print(terrain3DData.ControlMaps[0]);
}
}