Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Bad Code, sry] Dialog System

Discussion in 'Immediate Mode GUI (IMGUI)' started by XuPoH, Feb 19, 2015.

  1. XuPoH

    XuPoH

    Joined:
    Oct 4, 2014
    Posts:
    13
    Preamble: sorry for my awful English and bad code. If you are interest in more good version - you could feedback me here.

    In brief, my dialog system is made of:
    1) NodeEditor.cs - it's a basic window class inherited from EditorWindow. There you could create nodes, connect it with each other in the special sequence.
    2) NodeSerializable.cs, Node.cs - files which contains classes responsible for showing, serializing and saving the structure of your dialogs.
    3) NPCDialog - it's a class responsible for showing the dialog when the player stands near the NPC.

    Put 2), 3) in Assets/*anysubfolder*
    Put 1) in Assets/*anysubfolder*/Editor/ !

    Then go to Window/DialogEditor, to create NPC's question click RMB, then click Add question. To add player's answer - click RMB, then click Add answer.
    To navigate between questions I've added some commands: "end" will close the dialog, "goto %n" - will navigate to question with number %n (note: number is array index. It means that they always one less). Command should be in Action node (RMB->Add action).
    To change contents of node, double click it, you will see the TextArea. Put there something that you need, then double click again - it will apply changes and close the TextArea. When you starting to drag outside of the nodes, you will drag all nodes, when you scrolling, you will change size of the nodes.
    To connect question to answer(s), and answer(s) to action(s), you should target your mouse cursor at node A, then hold RMB and move cursor to node B, then release RMB. To disconnect from node, do the same thing, but hold Control button.
    To create NPC dialog - drag and drop NPCDialog script on your gameobject, and in field Dialog File Name enter relative path to your dialog without extention ("Dialogs/d0" example).

    When you created the dialog you needed, press the Save button and choose a destination folder. Your dialog will be saved as d%index%.xml file, but if it exists, it will increase %index% intil file won't exists.
    Phew! Hope it helps.
     

    Attached Files:

    Last edited: Feb 19, 2015
    Yuanfeng likes this.
  2. Korigoth

    Korigoth

    Joined:
    Jul 21, 2014
    Posts:
    105
    I tried you script and i have error in NPCDialog

    GUIManager
    Movement
    MouseLook

    are not found and i dont know where to get them...

    can you help ?
     
    GreenCubeGames likes this.