combine words of different scenes in a list or array; have each word link to a page

Hello everyone. I would like to ask a few questions.
Basically i am creating an educational puzzle game (form words).

My first question is that how do i combine all the words formed in each level into one scene? For example, player form 6 words in level1, form 8 words in level2 etc… So i will have a scene called “Revision” that allow player to refresh their memory on what words they have form in each level. Refer to the image for more details.

Second, whenever player finish level1, they will be proceed to level1Complete which will show them what words they have form in level1. Then i am intending to create a link that will direct them to an “explanation” page which will explain what the individual word mean? So how could i do about it??

Have one GameObject that won’t be destroyed on load, with a Script that stores the Strings in a List. Use custom unity google search ( Programmable Search Engine ). Search for loadlevel, dontdestroyonload, Array / List and String. Good Luck.

Greetz, Ky.

1 one GameObject ‘Manager’ with don’t destroy on load and and one var level01Words : List<String>; for each Level and a function FeedWord that takes level : int and word : String as Parameters. The Function then tests what level it got as input (you can do it with if-statements, but I’d rather search for switch/case). depending on level, add the word to the appropriate levelWords-List.

2 one empty GameObject in each Scene that cares for the word-creation.
needs a variable to store the reference to the ‘Manager’-Script. Search the reference in Start(). (to get the reference, google gameObject.Find and GetComponent and/or ‘access variables from another script’ or something).

when the word is done, feed it to Manager by calling it’s 'FeedWord’Function.

3 the same empty GameObject can have RevisionControl. This needs to reference the ManagerScript and read its Lists, then display them as buttons.

Edit: Oh, well… -.- here’s the code then…


var level01Words : List.<String> = new List.<String>();
var level02Words : List.<String> = new List.<String>();
// an new List of Strings is created and assigned to 'lvl01Words'.
// this List is currently empty.

function Awake ()
  // have this GameObject survive throughout all scenes.

/**************** what the following function does
we need a function that will later feed the Words into the empty Lists

we create a function that take two 'Parameters'
Parameters are like variables, just that they exist only inside their function.
we have to say, of what type these Parameters are
for some weird reason, they are separated by ',' insteat of ';'
when we call the function, we have to give the appropriate variables in the right order
(can't call: FeedWord(someString, someInt);
   but call: FeedWord(someInt, someString);
when calling the function, the values are assigned to the parameter-variable
so inside the function FeedWord the variable 'level' has now the value 'someInt'
and 'word' has now the value of 'someString' and the function will process that...


function FeedWord (level : int, word : String)
  switch (level)
    case 1:
    case 2:
      print("we are neither in lvl 1 nor 2...?");



var level : int; // set this value in the editor (level1 = '1', level2 = '2' etc.)
private var newWord : String; 
private var managerScript : ManagerScript; 
// the variable managerScript references the path to a Instance (=Copy) 
// of your self-defined Class 'ManagerScript'

function Start() 
  managerScript = gameObject.Find("Manager").GetComponent(ManagerScript);
  // if possible, reference-paths are always stored in function Start

  // depending on how you create the word, you might want to call
  // function CreateWord in function Start, in function Update or from another Button etc.
  /****** CreateWord(); 
just commented out for demonstration. 
Once the CreateWord-Function works propperly 
(= you have added the code that actually creates a word), 
you have to remove the *******/


function CreateWord ()
  // do stuff to create your word. When it's done:

  //newWord = the newly created word.

  managerScript.FeedWord(level, newWord); // adds newWord to the list of level-x-Words in Manager.js



var level : int; 
// again, set in editor to respective value.
// for final revision, set this to any other value. (e.g. '100')
private var manager : ManagerScript;

function Start ()
  manager = gameObject.Find("Manager").GetComponent(ManagerScript);

function OnGUI ()
  switch (level)
    case "1":
    case "2":
      // Default assumes we are in final revision and displays ALL words:

function DisplayButtons (levelWords : List.<String>)
   for (var i : int = 0; i< levelWords.Count; i++) 
   // create a new variable 'i : int' to use it inside the loop 
   // take 'element 0' (= the first word in the List) and do what is inside the loop,
   // then take the next element, do what's inside the loop,
   // ... and so on, until you are through with all elements
      if (GUI.Button (Rect((10 + (level-1)*60), (10 + i*30), 50, 20), levelWords*))*
_/**** what this last line of code does:_
_(10+(level-1)*60) sets the x-value of the topleft corner of the new button._ 
_if 'level' is 1, then this position is at (10+(1-1)*60) = 10._ 
*so all words of level1 draw in the first column at x-position = 10.* 
_if 'level' is 2, then this position is at (10+(2-1)*60) = 70._ 
*so all words of level2 draw in the second column at x-pos = 70.*
_(10+i*30) sets the y-value of the topleft corner of the new button._ 
*i = the first, second or third etc Word in the List we are currently checking.* 
_If i = 0 (=first word), then this pos is at (10+0*30) = 10._ 
*So all first words always draw in the top row at y-pos = 10.* 
_If i = 1 (=second word), then this pos is at (10+1*30) = 40._ 
*So all second words always draw in the second row at y-pos = 40.*
_*if i = 0 that's the first Word of the current String-List.*_ 
_*if i = 1 that's the second Word and so on.*_
 _*// if this button we just created gets clicked, do:*_
 _*// load the explaination-page depending on what 'theWord' is*_
_*Greetz, Ky.*_

//revisionControl->create empty object and attach to it on the scene “level1”

static var lvlStringList	:String[];

function Awake ()
	DontDestroyOnLoad (transform.gameObject);

function Update () 

//displayLevelsWord script that are attached to the scene "revision"
var level1Words : Transform;
var level2Words : Transform;
var level3Words : Transform;
var level4Words : Transform;
var level5Words : Transform;
var level6Words : Transform;
var level7Words : Transform;
var level8Words : Transform;
var level9Words : Transform;
var level10Words : Transform;

function Update () 
	level1Words.guiText.text +=revisionControl.lvlStringList+ "

// maybe i don’t know how to use the array of string, it display nothing on the scene.

I have try coding it but somehow it doesn’t work properly. I don’t really know how to use the arraylist or array of string.