Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


TryGetValue

Gets the value of a property by name.
Read time 2 minutesLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: Unity.Properties
  • Assembly: UnityEngine.PropertiesModule

TryGetValue<T, U>(T, string, T)

Gets the value of a property by name.
public static bool TryGetValue<TContainer, TValue>(TContainer container, string name, out TValue value)

Parameters

container

T
The container whose property value will be returned.

name

The name of the property to get.

value

T
When this method returns, contains the value associated with the specified name, if the property is found. otherwise the default value for the
TValue
.

Returns

Type

Description

bool
true
if the value exists for the specified name; otherwise,
false
.

TryGetValue<T, U>(T, string, T)

Gets the value of a property by name.
public static bool TryGetValue<TContainer, TValue>(ref TContainer container, string name, out TValue value)

Parameters

container

T
The container whose property value will be returned.

name

The name of the property to get.

value

T
When this method returns, contains the value associated with the specified name, if the property is found. otherwise the default value for the
TValue
.

Returns

Type

Description

bool
true
if the value exists for the specified name; otherwise,
false
.

TryGetValue<T, U>(T, PropertyPath, T)

Gets the value of a property by path.
public static bool TryGetValue<TContainer, TValue>(TContainer container, in PropertyPath path, out TValue value)

Parameters

container

T
The container whose property value will be returned.

The path of the property to get.

value

T
When this method returns, contains the value associated with the specified path, if the property is found. otherwise the default value for the
TValue
.

Returns

Type

Description

bool
true
if the value exists at the specified path; otherwise,
false
.

TryGetValue<T, U>(T, PropertyPath, T)

Gets the value of a property by path.
public static bool TryGetValue<TContainer, TValue>(ref TContainer container, in PropertyPath path, out TValue value)

Parameters

container

T
The container whose property value will be returned.

The path of the property to get.

value

T
When this method returns, contains the value associated with the specified path, if the property is found. otherwise the default value for the
TValue
.

Returns

Type

Description

bool
true
if the value exists at the specified path; otherwise,
false
.

TryGetValue<T, U>(T, PropertyPath, T, VisitReturnCode)

Gets the value of a property by path.
public static bool TryGetValue<TContainer, TValue>(ref TContainer container, in PropertyPath path, out TValue value, out VisitReturnCode returnCode)

Parameters

container

T
The container whose property value will be returned.

The path of the property to get.

value

T
When this method returns, contains the value associated with the specified path, if the property is found. otherwise the default value for the
TValue
.

returnCode

When this method returns, contains the return code.

Returns

Type

Description

bool
true
if the value exists at the specified path; otherwise,
false
.