0

My existing code for this task is:

private VisualElement _creditSection;

    private void Start()
    {
        var rootElement = uiDocument.rootVisualElement;
        
        _creditSection = rootElement.Q("CreditSection");

        Debug.Log(_creditSection.style.transitionDuration.value);
    }

However, I am receiving null for this in console. I understand it's because the value is of object type, but I don't know how to get the value of the transition duration.

2
  • 1
    are you maybe getting null for _creditSection due to that query rootElement.Q("CreditSection") failing? Like is it printing out null in the console or do you rather get a NullReferenceException? Commented Feb 15, 2024 at 8:24
  • @derHugo I'm sure It's correct. stackoverflow.com/a/77999961/16948694 Commented Feb 15, 2024 at 12:21

1 Answer 1

0

By chance, I discovered that I am able to get the value of transitionDuration using this code:

print(_creditSection.resolvedStyle.transitionDuration.First().value);

It seems that _creditSection.style is used for setting values, whereas resolvedStyle is used for getting values. Utilizing LINQ, we can extract the first value of transitionDuration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.