Author Topic: editable text in crossword puzzle  (Read 2771 times)

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
editable text in crossword puzzle
« on: July 10, 2014, 02:03:06 AM »
I am trying to make a game that is similar to a crossword puzzle.  I have a prefab that contains a sprite for each square, then I am thinking I would have an animation that shows a blinking cursor when a square is clicked (unless nGUI can do this).

What is the best way to handle having an editable text box for each cube (for a single letter).  I would create the cubes on the fly at the start of the puzzle based on the puzzle based on a prefab.   So each one of these would need to have it's own text field that is locked to the middle of the cube.

I'm really new to using nGUI and not sure the best way to set this up.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: editable text in crossword puzzle
« Reply #1 on: July 10, 2014, 08:51:21 PM »
An input field can be limited to have a certain maximum number of characters. You can set it to '1'.

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: editable text in crossword puzzle
« Reply #2 on: July 10, 2014, 08:56:44 PM »
An input field can be limited to have a certain maximum number of characters. You can set it to '1'.

I suspected that, but how do I tie it to the square.  Do I make sprites representing the square inside of UI camera game object?  Or is there a way to attach them to the prefabs outside of all the ui cameras. 

I want to dynamically create the play field instantiating the blocks I need based on the puzzle, then setting them up as I need and attaching the text field.

How do I dynamically create the cubes I need to represent the puzzle and have the UI attach to them?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: editable text in crossword puzzle
« Reply #3 on: July 10, 2014, 09:53:15 PM »
What do you mean by "tie it to the square"? Create a label, make it a square, put a collider and UIInput on it and change the max chars to 1.

Then save this as a prefab and instantiate it as many times as you need to create your puzzle board.

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: editable text in crossword puzzle
« Reply #4 on: July 10, 2014, 09:57:38 PM »
What do you mean by "tie it to the square"? Create a label, make it a square, put a collider and UIInput on it and change the max chars to 1.

Then save this as a prefab and instantiate it as many times as you need to create your puzzle board.

Those sprites (that are the squares where you enter the letters and have the input text box) would need to be instantiated under UI Root right? 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: editable text in crossword puzzle
« Reply #5 on: July 10, 2014, 10:03:09 PM »
Somewhere underneath it, sure -- using NGUITools.AddChild. Doesn't have to be directly under it, but they do need to be a part of the UI hierarchy.

Saxi

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: editable text in crossword puzzle
« Reply #6 on: July 10, 2014, 10:04:42 PM »
Somewhere underneath it, sure -- using NGUITools.AddChild. Doesn't have to be directly under it, but they do need to be a part of the UI hierarchy.

Ok, so as long as it is under UI Root, I can use it like any other game object?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: editable text in crossword puzzle
« Reply #7 on: July 11, 2014, 07:46:28 PM »
Yeah.