Exemple #1
0
 /// <summary>
 /// Constructs a <see cref="StringName"/> from the given <paramref name="name"/> string.
 /// </summary>
 /// <param name="name">String to construct the <see cref="StringName"/> from.</param>
 public StringName(string name)
 {
     if (!string.IsNullOrEmpty(name))
     {
         NativeValue          = (godot_string_name.movable)NativeFuncs.godotsharp_string_name_new_from_string(name);
         _weakReferenceToSelf = DisposablesTracker.RegisterDisposable(this);
     }
 }
Exemple #2
0
 /// <summary>
 /// Constructs a <see cref="NodePath"/> from a string <paramref name="path"/>,
 /// e.g.: <c>"Path2D/PathFollow2D/Sprite2D:texture:size"</c>.
 /// A path is absolute if it starts with a slash. Absolute paths
 /// are only valid in the global scene tree, not within individual
 /// scenes. In a relative path, <c>"."</c> and <c>".."</c> indicate
 /// the current node and its parent.
 /// The "subnames" optionally included after the path to the target
 /// node can point to resources or properties, and can also be nested.
 /// </summary>
 /// <example>
 /// Examples of valid NodePaths (assuming that those nodes exist and
 /// have the referenced resources or properties):
 /// <code>
 /// // Points to the Sprite2D node.
 /// "Path2D/PathFollow2D/Sprite2D"
 /// // Points to the Sprite2D node and its "texture" resource.
 /// // GetNode() would retrieve "Sprite2D", while GetNodeAndResource()
 /// // would retrieve both the Sprite2D node and the "texture" resource.
 /// "Path2D/PathFollow2D/Sprite2D:texture"
 /// // Points to the Sprite2D node and its "position" property.
 /// "Path2D/PathFollow2D/Sprite2D:position"
 /// // Points to the Sprite2D node and the "x" component of its "position" property.
 /// "Path2D/PathFollow2D/Sprite2D:position:x"
 /// // Absolute path (from "root")
 /// "/root/Level/Path2D"
 /// </code>
 /// </example>
 /// <param name="path">A string that represents a path in a scene tree.</param>
 public NodePath(string path)
 {
     if (!string.IsNullOrEmpty(path))
     {
         NativeValue          = (godot_node_path.movable)NativeFuncs.godotsharp_node_path_new_from_string(path);
         _weakReferenceToSelf = DisposablesTracker.RegisterDisposable(this);
     }
 }
Exemple #3
0
        public void Dispose(bool disposing)
        {
            // Always dispose `NativeValue` even if disposing is true
            NativeValue.DangerousSelfRef.Dispose();

            if (_weakReferenceToSelf != null)
            {
                DisposablesTracker.UnregisterDisposable(_weakReferenceToSelf);
            }
        }
Exemple #4
0
 private NodePath(godot_node_path nativeValueToOwn)
 {
     NativeValue          = (godot_node_path.movable)nativeValueToOwn;
     _weakReferenceToSelf = DisposablesTracker.RegisterDisposable(this);
 }
Exemple #5
0
 private StringName(godot_string_name nativeValueToOwn)
 {
     NativeValue          = (godot_string_name.movable)nativeValueToOwn;
     _weakReferenceToSelf = DisposablesTracker.RegisterDisposable(this);
 }