About 'Unity Scriptable Objects'!

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.

3 Likes

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;

1 Like

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.

1 Like

Alright then. I’ll work on getting that done when I get an opportunity.

1 Like

Sure, just reply here with the zip file link and I’ll take a look. :slight_smile:

1 Like

help me rob.zip (1.8 MB)

Thanks in advance!

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.

image

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. :slight_smile:

1 Like

Oh, huh. Thanks a lot for looking! Guess I’ll just restart it then.

… Did you like the name of the zip file :3

1 Like

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 :slight_smile:

1 Like

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!

1 Like

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 :slight_smile:

1 Like

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.

1 Like

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.

  1. Make sure you Save your script in Visual Studio before coming back to Unity

  2. 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.

  1. Make sure you Save your script in Visual Studio before coming back to Unity

  2. Once you are back in Unity, Right-Click and Refresh.

2 Likes

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

Privacy & Terms