FlatRedBall.Glue.ElementRuntime.GetCustomVariable C# (CSharp) Method

GetCustomVariable() public method

public GetCustomVariable ( string variableName, VariableGetType variableGetType = VariableGetType.DefinedInIElement ) : CustomVariable
variableName string
variableGetType VariableGetType
return FlatRedBall.Glue.SaveClasses.CustomVariable
        public CustomVariable GetCustomVariable(string variableName, VariableGetType variableGetType = VariableGetType.DefinedInIElement)
        {
            if (variableGetType == VariableGetType.AsExistsAtRuntime)
            {
                PropertyValuePair? foundPvp = null;

                foreach (var variable in mCustomVariables)
                {
                    if (variable.Property == variableName)
                    {
                        foundPvp = variable;
                        break;
                    }
                }

                if (foundPvp.HasValue)
                {
                    CustomVariable customVariable = mAssociatedIElement.GetCustomVariableRecursively(variableName);

                    if (customVariable != null)
                    {
                        CustomVariable toReturn = customVariable.Clone();
                        toReturn.DefaultValue = foundPvp.Value.Value;
                        return toReturn;
                    }
                }
                return null;
            }
            else
            {
                // mAssociatedIElement is null if an object is created for a missing object (like a Sprite)
                if (mAssociatedIElement != null)
                {
                    CustomVariable customVariable = mAssociatedIElement.GetCustomVariableRecursively(variableName);

                    return customVariable;
                }
            }
            return null;
        }