Hi all. My problem isn´t too important but I would still like to fix it. When i created the text file where I wrote the
challenge and I saved in visual studio into my assets file it looked different than in the video and also if i try to open the visual studio text file it wont let me. It only shows up when I open the state script.
It could be that you saved it as something other than a .txt file (text file). Normally we dont use Visual Studio to keep notes like this, so Visual Studio isn’t really expecting us save the file as a text file.
I had the same issue (no “State” option on the Create Asset sub-menu). I found this solution:
- Right-Click in the Asset Area
- Choose “Refresh” from the Asset Menu (command-R on my mac)
The option to create a “State” now appears on the Create sub-menu
I had to reboot my computer after installing Visual Studio 2017, in order to get the syntax highlighting and code hints to work. A friendly response from the Facebook group led me in this direction, but it would be nice to have a note in this video because this was the first one that I noticed it was an issue.
I have the exact same script, but it dosen’t show up. It cannot recognize CreateAssetMenu, giving me an error.
o:— Game Stuff\New folder\Assets\State.cs(2,2): Error CS0246: The type or namespace name ‘CreateAssetMenu’ could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp)
Hi Wrys,
Could you post your script please?
See also;
- Forum User Guides : How to apply code formatting within your post
When we first got the error we just copy and pasted the script from this lecture. It’s exactly the same. If you still need me to send it I can, but it’s just the script at this point of the lecture.
Hi Wrys,
There shouldn’t be a problem with that script, it is, after all, working for many others. But let’s see if we can find out why it isn’t working for you.
If you zip up your project files and share them with me I will take a quick look and see if anything stands out.
The forum will allow uploads of up to 10MB, if your project files (zipped) are larger than that you would need to use a service such as Google Drive or Dropbox, and then share the URL.
Alright then. I’ll work on getting that done when I get an opportunity.
Sure, just reply here with the zip file link and I’ll take a look.
Hi,
Ok, so I have your project, I’ve run the game, I see some text “I was added programmatically” and there are no errors.
So the script appears to be fine. If you haven’t already, try closing Unity and re-launching it, re-opening your project. Looks ok at this end though.
Oh, huh. Thanks a lot for looking! Guess I’ll just restart it then.
… Did you like the name of the zip file :3
hehe, yeah, very good.
There’s a note above by @StormFolio who mentioned he used Unity’s refresh option which resolved the issue of not having State on the Create menu, but he doesn’t mention the error that you received.
Try closing/re-opening and see if that fixes the issue first, but code wise, its all good
I saw that and thought it’d be the solution but when I tried nothing happened. Good to know the code is all good though! Thanks a lot for the help! Should be able to go through to the course as usual now!
Thanks a lot for the help! Should be able to go through to the course as usual now!
You’re very welcome and cool - enjoy
I’ve had no issues just want to say a big THANK YOU! because having done the original version (prison break), this is a much better way to do a Text Game, so again THANK YOU SO MUCH! States are amazing.
I know some are having problems with Right-Clicking in the Assets area and not having the option to Create->State.
I had this issue as well, and it turns out there are two important things to do so you can do this.
-
Make sure you Save your script in Visual Studio before coming back to Unity
-
Once you are back in Unity, Right-Click and Refresh.
I know many are having problems with Right-Clicking in the Assets area and not having the option to Create->State.
I had this issue as well, and it turns out there are two important things to do so you can do this.
-
Make sure you Save your script in Visual Studio before coming back to Unity
-
Once you are back in Unity, Right-Click and Refresh.
Hi, towards the end of this lecture i noticed my Unity console displaying an error and I’d like to know why.
Assets\AdventureGame.cs(10,27): warning CS0649: Field ‘AdventureGame.titleText’ is never assigned to, and will always have its default value null
Here is my AdventureGame script :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdventureGame : MonoBehaviour
{
[SerializeField] Text storyText;
[SerializeField] Text titleText;
// Start is called before the first frame update
void Start()
{
storyText.text = ("You may have discovered the most amazing oppourtunity to ") +
("quickly make millions...") +
("You're going to rob a bank...");
titleText.text = ("Let's Rob A Bank");
}
// Update is called once per frame
void Update()
{
}
}
Any help? Thanks