Parsing error cs8025

private void LoadImages()

string pathPrefix = @"file://";
string pathImageAssets = @"C:\Assets\Pictures\";
string pathSmall = @"small\";
string filename = @"1";
string fileSuffix = @".jpg";

for (int=0; i<2; i++);
{
string indexSuffix = "";
float logIdx = Mathf.Log10(i+1);
if (ligIdx < 1.0)
indexSuffix += "00";
else if (logIdx < 2.0)
indexSuffix += "0";
indexSuffix += (i+1);

string fullFilename = pathPrefic +pathImageAssets + pathSmall + filename
WWW www = new WWW(fullFilename)
Texture2D texTmp = new Texture2D(320, 320, TextureFormat.DXT1, false)
www.LoadImageIntoTexture(texTmp);

imageBuffer.Add(texTmp);
}

It says there’s a parsing error at (3,6)
I want to cleare it to test if it works. And I don’t want to load into a texture, rather to a spec. place on the screen, how shall I rewrite?
It’s enough to answer just my first question, I will find out the rest :slight_smile: But your help would be appreciated.

I tried to write that a lot of places. Where do you exactly think I should write it?

Yeah, thanks :)

1 Answer

1

CS8025 is a parsing error, meaning that your syntax is incorrect. This can always be equated to a mistake when writing the code (as opposed to a runtime error). In you’re case, you’re missing some curly braces. Here is Fixed code:

private void LoadImages()
{ // <-------------------------Missing Curly
string pathPrefix = @"file://";
string pathImageAssets = @"C:\Assets\Pictures\";
string pathSmall = @"small\";
string filename = @"1";
string fileSuffix = @".jpg";
 
for (int=0; i<2; i++);
{
string indexSuffix = "";
float logIdx = Mathf.Log10(i+1);
if (ligIdx < 1.0)
{ //<--------------------missing curly (though, optional)
indexSuffix += "00";
} //<--------------------missing curly
else if (logIdx < 2.0)
{ //<--------------------missing curly
indexSuffix += "0";
indexSuffix += (i+1);
} //<--------------------missing curly
} //<--------------------missing curly (ends for loop)
string fullFilename = pathPrefic +pathImageAssets + pathSmall + filename
WWW www = new WWW(fullFilename)
Texture2D texTmp = new Texture2D(320, 320, TextureFormat.DXT1, false)
www.LoadImageIntoTexture(texTmp);
 
imageBuffer.Add(texTmp);
}

My suggestion is to format your code better using indentation on scope changes so that you can easily spot these errors.

i.e:

private void LoadImages()
{ // <-------------------------Missing Curly
    string pathPrefix = @"file://";
    string pathImageAssets = @"C:\Assets\Pictures\";
    string pathSmall = @"small\";
    string filename = @"1";
    string fileSuffix = @".jpg";

    for (int=0; i<2; i++);
    {
        string indexSuffix = "";
        float logIdx = Mathf.Log10(i+1);

        if (ligIdx < 1.0)
        { //<--------------------missing curly (though, optional)
            indexSuffix += "00";
        } //<--------------------missing curly
        else if (logIdx < 2.0)
        { //<--------------------missing curly
            indexSuffix += "0";
            indexSuffix += (i+1);
        } //<--------------------missing curly
    } //<--------------------missing curly (ends for loop)

    string fullFilename = pathPrefic +pathImageAssets + pathSmall + filename
    WWW www = new WWW(fullFilename)
    Texture2D texTmp = new Texture2D(320, 320, TextureFormat.DXT1, false)
    www.LoadImageIntoTexture(texTmp);

    imageBuffer.Add(texTmp);
}

Now I get the following errors: Parsing erroe (2,1) but I think that { should be there. (1,14) CS0116: A namespace can only contain types and namespace declarations - This error hadn't showed up. Sometimes it does when I change something but I don't see the problem there. Or the problem is somewhere in the script?

It is nice you turn my short comment as a long answer but make sure you pick the whole thing up. You forgot the ; after the two lines: string fullFilename = pathPrefic +pathImageAssets + pathSmall + filename WWW www = new WWW(fullFilename)

Concerning your namespace error, you would not have removed the class declaration by any chance?

;-s are there but still get the (2,1) parsing error Code hasn't been touched expect the curles so it's the same by functionality. I will gnaw it through or write an other script later but I am a bit tired right now. Any idea please let me know.

Just to make sure you have a .cs script and it starts with a few using UnityEngine; and using System.Collection; or other usings of the type and then you get public class ClassName:MonoBehaviour{} and inside of this you have your method.