GlueViewOfficialPlugins.Scripting.MethodCallParser.GetCustomVariableFromNosOrElement C# (CSharp) Method

GetCustomVariableFromNosOrElement() public static method

public static GetCustomVariableFromNosOrElement ( ElementRuntime elementRuntime, string variableName ) : CustomVariable
elementRuntime FlatRedBall.Glue.ElementRuntime
variableName string
return FlatRedBall.Glue.SaveClasses.CustomVariable
        public static CustomVariable GetCustomVariableFromNosOrElement(ElementRuntime elementRuntime, string variableName)
        {
            CustomVariable variable = elementRuntime.AssociatedIElement.GetCustomVariableRecursively(variableName);



            if (variable != null)
            {

                // The NOS may be overwriting the value from the element, so we need to set that if so:
                if (elementRuntime.AssociatedNamedObjectSave != null)
                {
                    NamedObjectSave nos = elementRuntime.AssociatedNamedObjectSave;

                    InstructionSave instruction = nos.GetInstructionFromMember(variable.Name);

                    if (instruction != null && instruction.Value != null)
                    {
                        variable = variable.Clone();
                        variable.DefaultValue = instruction.Value;
                    }
                }
            }
            return variable;
        }