[Unity Combat] Drama Dialogue (ii)

Source: Internet
Author: User

In the previous article, we write the instructions directly in the Commandmanager, in fact, this is very bad, because a game may appear a lot of drama animation, then is not to write n classes? And it's not very good to change them. So a better way is to write an editor class.


The following is I write an editor class, the function is not very perfect, such as can add "Insert command", "read command from Text" and so on, etc., but the first will be used.

Using unityengine;using unityeditor;using system.collections.generic;public enum option{commanddestory, CommandDial Ogue, Commanddialoguemodeenter, Commanddialoguemodeexit, Commandgenerate, Commandmove, CommandMusic, Com Mandplayanim, Commandrotate, Commandwait}public class window:editorwindow{list<option> options = new Lis    T<option> ();    list<string[]> strings = new list<string[]> ();    list<int[]> ints = new list<int[]> ();    list<float[]> floats = new list<float[]> ();    list<vector3[]> vector3s = new list<vector3[]> (); Vector2 v2 = new Vector2 (0, 0);//scroll bar parameter [MenuItem ("window/my window")] static void Init () {editorwindow.ge    Twindow (typeof (Window));        } void Ongui () {if (Guilayout.button ("Save Command")) {} if (Guilayout.button ("Add Command"))            {Option x = option.commanddialoguemodeenter; Options.            ADD (x); StrinG[] A = new string[5]; Strings.            Add (a);            Int[] B = new Int[5]; INTs.            ADD (b);            Float[] C = new float[5]; Floats.            ADD (c);            Vector3[] D = new vector3[5]; Vector3s.        ADD (d); } if (Guilayout.button ("Delete command")) {options. RemoveAt (options.            COUNT-1); Strings. RemoveAt (options.            COUNT-1); INTs. RemoveAt (options.            COUNT-1); Floats. RemoveAt (options.            COUNT-1); Vector3s. RemoveAt (options.        COUNT-1);        } v2 = Editorguilayout.beginscrollview (v2,false,true,null); for (int i = 0; i < options. Count;            i++) {Options[i] = (option) editorguilayout.enumpopup ("Options" + I, options[i]); Switch (Options[i]) {case Option.commanddestory:strings[i][0] = Editorguila Yout.                    TextField ("Object name", Strings[i][0]);                Break              Case Option.commanddialogue:      Strings[i][0] = Editorguilayout.textfield ("XML literal Name", strings[i][0]);                    Ints[i][0] = Editorguilayout.intfield ("Start serial number", ints[i][0]);                    INTS[I][1] = Editorguilayout.intfield ("End serial number", ints[i][1]);                    INTS[I][2] = Editorguilayout.intfield ("Number of steps performed after Click", Ints[i][2]);                Break                Case Option.CommandDialogueModeEnter:break;                Case Option.CommandDialogueModeExit:break;                    Case Option.commandgenerate:strings[i][0] = Editorguilayout.textfield ("Object name", Strings[i][0]);                    Vector3s[i][0] = Editorguilayout.vector3field ("Generate position", vector3s[i][0]);                    VECTOR3S[I][1] = Editorguilayout.vector3field ("Generation Angle", vector3s[i][1]);                Break                    Case Option.commandmove:strings[i][0] = Editorguilayout.textfield ("Object name", Strings[i][0]); Vector3s[i][0] = editorgUilayout.vector3field ("End position", vector3s[i][0]);                    Floats[i][0] = Editorguilayout.floatfield ("Time Spent", floats[i][0]);                Break                    Case Option.commandmusic:strings[i][0] = Editorguilayout.textfield ("Musical name", Strings[i][0]);                Break                    Case Option.commandplayanim:strings[i][0] = Editorguilayout.textfield ("Object name", Strings[i][0]);                    Ints[i][0] = Editorguilayout.intfield ("Animated state", Ints[i][0]);                Break                    Case Option.commandrotate:strings[i][0] = Editorguilayout.textfield ("Object name", Strings[i][0]);                    Vector3s[i][0] = Editorguilayout.vector3field ("End angle", vector3s[i][0]);                    Floats[i][0] = Editorguilayout.floatfield ("Time Spent", floats[i][0]);                Break        Case Option.commandwait:floats[i][0] = Editorguilayout.floatfield ("Wait Time", floats[i][0]);            Break            Default:break;    }} editorguilayout.endscrollview (); }}


[Unity Combat] Drama Dialogue (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.