mirror of https://github.com/godotengine/godot
C#: Fix dictionary key lookup documentation
The method to check if a key exists in the dictionary is called `ContainsKey`.
(cherry picked from commit 6723b4e8c3)
This commit is contained in:
parent
4c34531499
commit
c99f67105f
|
|
@ -41,7 +41,7 @@
|
||||||
{
|
{
|
||||||
// Check position if it is relevant to you
|
// Check position if it is relevant to you
|
||||||
// Otherwise, just check data
|
// Otherwise, just check data
|
||||||
return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().Contains("expected");
|
return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().ContainsKey("expected");
|
||||||
}
|
}
|
||||||
[/csharp]
|
[/csharp]
|
||||||
[/codeblocks]
|
[/codeblocks]
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
[csharp]
|
[csharp]
|
||||||
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
public override bool _CanDropData(Vector2 atPosition, Variant data)
|
||||||
{
|
{
|
||||||
return data.VariantType == Variant.Type.Dictionary && dict.AsGodotDictionary().Contains("color");
|
return data.VariantType == Variant.Type.Dictionary && dict.AsGodotDictionary().ContainsKey("color");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _DropData(Vector2 atPosition, Variant data)
|
public override void _DropData(Vector2 atPosition, Variant data)
|
||||||
|
|
|
||||||
|
|
@ -217,9 +217,9 @@
|
||||||
{ 210, default },
|
{ 210, default },
|
||||||
};
|
};
|
||||||
|
|
||||||
GD.Print(myDict.Contains("Godot")); // Prints true
|
GD.Print(myDict.ContainsKey("Godot")); // Prints true
|
||||||
GD.Print(myDict.Contains(210)); // Prints true
|
GD.Print(myDict.ContainsKey(210)); // Prints true
|
||||||
GD.Print(myDict.Contains(4)); // Prints false
|
GD.Print(myDict.ContainsKey(4)); // Prints false
|
||||||
[/csharp]
|
[/csharp]
|
||||||
[/codeblocks]
|
[/codeblocks]
|
||||||
In GDScript, this is equivalent to the [code]in[/code] operator:
|
In GDScript, this is equivalent to the [code]in[/code] operator:
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@
|
||||||
new Godot.Collections.Dictionary
|
new Godot.Collections.Dictionary
|
||||||
{
|
{
|
||||||
{ "name", "myOption" },
|
{ "name", "myOption" },
|
||||||
{ "defaultValue", false },
|
{ "default_value", false },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -157,12 +157,12 @@
|
||||||
return true
|
return true
|
||||||
[/gdscript]
|
[/gdscript]
|
||||||
[csharp]
|
[csharp]
|
||||||
public void GetOptionVisibility(string option, Godot.Collections.Dictionary options)
|
public void _GetOptionVisibility(string option, Godot.Collections.Dictionary options)
|
||||||
{
|
{
|
||||||
// Only show the lossy quality setting if the compression mode is set to "Lossy".
|
// Only show the lossy quality setting if the compression mode is set to "Lossy".
|
||||||
if (option == "compress/lossyQuality" && options.Contains("compress/mode"))
|
if (option == "compress/lossy_quality" && options.ContainsKey("compress/mode"))
|
||||||
{
|
{
|
||||||
return (int)options["compress/mode"] == COMPRESS_LOSSY; // This is a constant you set
|
return (int)options["compress/mode"] == CompressLossy; // This is a constant you set
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue