Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Method Access Exception

Discussion in 'Editor & General Support' started by rsimsek50, Aug 3, 2015.

  1. rsimsek50

    rsimsek50

    Joined:
    Jun 12, 2015
    Posts:
    7
    Hi,

    I have been quite new to Unity. I am trying to build a grammar app as a project. What my project does is, it basically reads a text file. After reading the text file it parses these sentences. Each time it brings the full sentence which has 4 words and you need to find the noun. When you find the noun, it brings the next sentences. Every words is set on a button. When you click the right button, it goes to next. I want to run this app on the web. I have built the app for web. When i run the app on the browser, it brings the default for 4 to set the game then it goes blank when you click the noun. When i run the app on unity, it works. Any help would be really appreciated.

    Thanks

    Remzi.
     
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    What is the exact exception you are getting? On which platform do you have problems? How are you loading the text file? Do you include the text file in Unity? If so, where exactly do you have it?
     
  3. rsimsek50

    rsimsek50

    Joined:
    Jun 12, 2015
    Posts:
    7
    It is private/protected method exception i was getting then i made everything public but it still does not work. It does not on the browser. I read the file with Streamreader method. I have included the text file inside the unity project in my folder. I do not know where should i put the text file ?
     
  4. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    What is the exact error message?
    Are you creating a web player?

    Please show the code with which you are loading the file and creating the stream to read it. Please use code tags:
    http://forum.unity3d.com/threads/using-code-tags-properly.143875/
     
  5. rsimsek50

    rsimsek50

    Joined:
    Jun 12, 2015
    Posts:
    7
    Here is the code i am reading the text file.

    Code (CSharp):
    1. string text;
    2.         string file = @"C:\Unity Project\English App\nouns.txt";
    3.         StreamReader fileReader = new StreamReader(file,Encoding.Default);
    4.         text = fileReader.ReadToEnd();
    5.         string[] lines = Regex.Split (text,"\r\n");
    I haven't created a webplayer. I am not sure how to do that.
     
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    On which platform are you trying to run it?
     
  7. rsimsek50

    rsimsek50

    Joined:
    Jun 12, 2015
    Posts:
    7
    I am trying to run it on Unity Web Player.
     
  8. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You can't use a StreamReader in the Web Player because of security reasons. You have to use WWW instead:
    http://docs.unity3d.com/ScriptReference/WWW.html

    And it is important to note that:
     
  9. rsimsek50

    rsimsek50

    Joined:
    Jun 12, 2015
    Posts:
    7
    When I use www, where should i put my text file? How should i give url which points that text file? I am quite confused to be honest. I have tried to use www but does not run at all.
     
  10. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The main question for me is, what are you trying to achieve? Do you want to create the game for the web player? Do you want to be able to update those text files without updating the application?
     
  11. rsimsek50

    rsimsek50

    Joined:
    Jun 12, 2015
    Posts:
    7
    Basically what i want to achieve is that, i want to just read the text file and put the sentences into the buttons. I don't want to update the text file at the moment. If i want to extend the game in the future, it will be a update to the text file which will be done by manually. I need to read this file and use the information while i play this game on the web browser.