Hello, I am sorry if I have posted in the wrong page but I need some advice. Just to give you a little information about me. My name is Stuart I'm 26 I love technology and everything about it. I have decided I wanted to self learn about game development. So I thought an easy place to start was Android gaming apps. I found a book called 'Unity Android Game Development by Example (beginner's guide)' written by Thomas Finnegan. I don't know if anyone is familiar with this book. I have hit a stumble. I have followed the book word for word. I just don't seem to have any luck getting the finished app. The Task is to create the app 'Hello World'. The book tells me to Create a C# Script from the menu in the project window. once I have named it HelloWorld Hit enter twice to open the Script up. Then action 17. say's "For now we will delete the start and update functions that Unity insists on including in every new script. Replace them with a bit of code that simply renders the words Hello World in the top-left corner of the screen. You can now close the script and return to unity. public void OnGUI() { GUILayout.Label("Hello World"); } I hope this helps and I am sorry for being a newbie. I just want to learn. Thank Stuart
Daniel it tells me to drag the script to the Hierarchy window and drop it on the main camera object which I have done
You're certain it isn't just very small text? Try this and let us know what is being reported in the console. Code (csharp): public void OnGUI() { GUILayout.Label("Hello World"); Debug.Log ("This should get logged in the Console"); }
On The screenshots in your rar file you did not finish the script and did not save it. You are missing the closing bracket of the class in the end.
The script is still not saved so it will not be effective within the editor. File -> Save in Notepad++
Thanks Josh!!! In the book it doesn't ask to save the Notepad++ you have solved my Problem and thank you to fffMalzbier, DanielQuick, Graham Dunnett for all your help!!
Hey Guys Back again. This is my good for a Tick Tac Toe game but I have an error message I need help error message: Assets/SquareState.cs(6,13): error CS0542: `SquareState.SquareState': member names cannot be the same as their enclosing type Please help PS thanks so much for helping. Code (CSharp): public class SquareState : MonoBehaviour { public enum SquareState { Clear, XControl, OControl } }
the enum <name> is the same as the class <name> this is not allowed in c# you can do something like this: Code (CSharp): public class Square : MonoBehaviour { public enum SquareState { .... } }
I change it and it doesn't like it either. I have another script Code (CSharp): using UnityEngine; using System.Collections; public class SquareState : MonoBehaviour { public enum SquareState { Clear, XControl, OControl } } Code (CSharp): using UnityEngine; using System.Collections; public class TicTacToeControl : MonoBehaviour { public SquareState[] board = new SquareState[9]; public bool xTurn = true; public void OnGUI() { float width = 75; float height = 75; for(int y=0;y<3;y++) { for(int x=0;x<3;x++) { int boardIndex = (y * 3) + x; Rect square = new Rect (x * width, y * height, width, height); string owner = board[boardIndex] == SquareState.XControl ? "X" : board[boardIndex] == SquareState.OControl ? "O" : ""; if(GUI.Button(square, Owner)) SetControl (boardIndex); } } } public void SetControl(int boardIndex) { if(boardIndex < 0 || boardIndex >= board.Length) return; board[boardIndex] = xTurn ? SquareState.XControl : SquareState. OControl; xTurn = !xTurn; } } These are my 2 scripts so far. Top one Titled SquareState Bottom one titled TicTacToeControl
read the error msg: SquareState.SquareState': member names cannot be the same as their enclosing type and than look into your SquareState class.
Hi TRuoss I do apologies I am still learning and I changed the details like you said earlier but it made more errors.
If a change makes more errors, it doesn't necessarily mean that it was the wrong change. Just that the first error was hiding many others.
your following errors come from this, i think: Code (CSharp): string owner = board[boardIndex] == SquareState.XControl ? "X" : board[boardIndex] == SquareState.OControl ? "O" : ""; after changing the first file you have to change this to Square.SquareState.XControl. if you had named the class Square
Cheers TRuoss I am going to have another pop at this today. decided to rest my brain for a couple of days.