Search Unity

Feedback Node Editor TextField data

Discussion in 'Works In Progress - Archive' started by stevh90, May 7, 2020.

  1. stevh90

    stevh90

    Joined:
    May 23, 2017
    Posts:
    2
    Hello,
    I'm currently working on creating a node based editor for a dialogue system, which will be used for creating a Visual Novel. The issue that I'm having is that I can't seem to gain access to the TextField value. I know that this:

    textField.RegisterValueChangedCallback(evt =>
    {
    node.DialogueText = evt.newValue;
    });

    Works in terms of creating an individual Text Field, however in my case I'm trying to gain access to multiple TextField data; shown in the attached image below.

    Capture.PNG

    By clicking on the "Dialogue +" button, a new TextField will be generated into the node's main container. So in the end I'm trying to do is gain access to each TextField's data so that I can save them into an asset file.

    If you have any knowledge on how to do this, please feel free to comment below.
     
  2. stevh90

    stevh90

    Joined:
    May 23, 2017
    Posts:
    2
    Right now I'm using this bit of code below to temporary solve my problem but it is messy and not very reliable.

    string parentS = "", childS = "";
    for (int i = 0; i < _narratorNode.mainContainer.childCount; i++)
    {
    if (_narratorNode.mainContainer.ElementAt(i).GetType() == typeof(TextField))
    {
    var p = (TextField)_narratorNode.mainContainer.ElementAt(i);
    parentS = p.value;
    for (int j = 0; i < p.childCount; i++)
    {
    if (p.ElementAt(i).name =="Narrative")
    {
    var c = (TextField)p.ElementAt(i);
    childS = c.value;
    Debug.Log(childS);
    }
    }
    }
    Debug.Log(parentS);
    }