Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
using System;
using UnityEngine;
using System.Collections.Generic;

namespace Sirenix.SerializationData
{
[Serializable]
public struct SerializationData
{
[SerializeField]
public DataFormat SerializedFormat;
[SerializeField]
public byte[] SerializedBytes;
[SerializeField]
public List<object> ReferencedUnityEngine.Objects;
[SerializeField]
public string SerializedBytesString;
[SerializeField]
public Object Prefab;
[SerializeField]
public List<object> PrefabModificationsReferencedUnityEngine.Objects;
[SerializeField]
public List<string> PrefabModifications;
[SerializeField]
public List<serializationnode> SerializationNodes;
}
}

What I have tried:

Almost everything I need it done
Posted
Updated 29-May-23 23:25pm
v2
Comments
Dave Kreskowiak 26-May-23 18:25pm    
You have to give the exact error message, not just the error number.
Zac Raleigh 27-May-23 11:14am    
error cs1026 expected

As already mentioned, the code in your question doesn't produce a CS1026 error. Instead, it produces two CS0106 errors:
Compiler Error CS0106 | Microsoft Learn[^]

The problem is that you have two fields with invalid names:
C#
public List<object> ReferencedUnityEngine.Objects;
...
public List<object> PrefabModificationsReferencedUnityEngine.Objects;
The compiler thinks that these are explicit interface implementations, which cannot have access modifiers applied to them.

But in reality, the problem is that field names cannot contain . characters.

Depending on what you're actually trying to do, you probably need a separate class:
C#
[Serializable]
public class ObjectWrapper
{
    [SerializeField]
    public List<object> Objects;
}
You would then change your properties to hold an instance of that class:
C#
[Serializable]
public struct SerializationData
{
    ...
    [SerializeField]
    public ObjectWrapper ReferencedUnityEngine;
    ...
    [SerializeField]
    public ObjectWrapper PrefabModificationsReferencedUnityEngine;
    ...
}
 
Share this answer
 
The error isn't in that code: CS1026 is "')' Expected" and there are no '(' or ')' characters in that code, so there is no reason for the compiler to give you that error.

It's somewhere else - and we can't see the rest of your code, or the actual error report.
But error messages hold a lot of data if you look at them properly. See here: How to Write Code to Solve a Problem, A Beginner's Guide Part 2: Syntax Errors[^] and look at your error message carefully as it describes.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900