Announcement

Collapse
No announcement yet.

Nesting TArray's inside TSharedRef

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Nesting TArray's inside TSharedRef

    Is it possible to best a TArray inside a TSharedRef?

    Something similar to

    TArray<int32> Variable;
    TSharedRef<Test> MySharedRef[Variable] = Test;

    Where I'd then be able to reference a dynamic TSharedRef via a TArray like

    MySharedRef[1]
    (results #1 TSharedRef instead of int)

    ???
    can't figure it out
    The only similar post I've found is here
    https://answers.unrealengine.com/que...ay-of-str.html

    and I'm not able to get that to work with what I'm attempting neither

    help is much appreciated!

  • #2
    TSharedRef<TArray<int32>> ?

    Your post makes almost no sense, so it's not clear what you are trying to achieve.

    Comment


    • #3
      TSharedRef<TArray<STextBox>> TextBox;
      TextBox[1] = SNew(STextBox);
      TextBox[2] = SNew(STextBox);

      Something like this but it has compilation issues

      Comment


      • #4
        you are doing it the wrong way.
        The array should have tsharedref inside of it.
        TArray<TSharedRef<STextBox>> TextBoxes

        now you can actually do:
        TSharedRef<STextBox> mytextbox = SNew(..);
        TextBoxes.Add(mytextbox);

        TSharedRef<STextBox> mySecondTextbox = SNew(..);
        TextBoxes.Add(mySecondTextbox);

        Then you can access it through TextBoxes[0], and TextBoxes[1] respectively.

        You should actually read a tutorial on C++ (since I saw your other post too, and you are a bit confused about arrays)
        Check my User Interface Kit here: https://forums.unrealengine.com/show...-Interface-Kit
        A WIP Hex Planet Generation: https://forums.unrealengine.com/show...ral-Generation

        Comment


        • #5
          Also, another mistake you are doing is trying to access the FIRST value of an ARRAY using 1.
          The first value is accessed with a zero index: myArray[0]! Indexes start from 0..
          Check my User Interface Kit here: https://forums.unrealengine.com/show...-Interface-Kit
          A WIP Hex Planet Generation: https://forums.unrealengine.com/show...ral-Generation

          Comment

          Working...
          X