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. Dismiss Notice

Issue with Generate collection code for Ghost Collection Authoring Component (Trying before classes)

Discussion in 'Entity Component System' started by RyancHaynes, Jul 31, 2020.

  1. RyancHaynes

    RyancHaynes

    Joined:
    Dec 8, 2018
    Posts:
    11
    Unity 2020.1.0b5

    Whenever I use the Generate Collection Code feature for Ghost Collection Authoring Component the script that is generated contains Trying Keywords before every class.

    EX)
    public struct Trying intGhostSerializerCollection : IGhostSerializerCollection
    {
    #if UNITY_EDITOR || DEVELOPMENT_BUILD
    public string[] CreateSerializerNameList()
    {
    var arr = new string[]
    {
    "CubeGhostSerializer",
    };
    return arr;
    }

    public int Length => 1;
    #endif
    public static int FindGhostType<T>()
    where T : struct, ISnapshotData<T>
    {
    if (typeof(T) == typeof(CubeSnapshotData))
    return 0;
    return -1;
    }

    public void BeginSerialize(ComponentSystemBase system)
    {
    m_CubeGhostSerializer.BeginSerialize(system);
    }

    public int CalculateImportance(int serializer, ArchetypeChunk chunk)
    {
    switch (serializer)
    {
    case 0:
    return m_CubeGhostSerializer.CalculateImportance(chunk);
    }

    throw new ArgumentException("Invalid serializer type");
    }

    public int GetSnapshotSize(int serializer)
    {
    switch (serializer)
    {
    case 0:
    return m_CubeGhostSerializer.SnapshotSize;
    }

    throw new ArgumentException("Invalid serializer type");
    }

    public int Serialize(ref DataStreamWriter dataStream, SerializeData data)
    {
    switch (data.ghostType)
    {
    case 0:
    {
    return GhostSendSystem<Trying intGhostSerializerCollection>.InvokeSerialize<CubeGhostSerializer, CubeSnapshotData>(m_CubeGhostSerializer, ref dataStream, data);
    }
    default:
    throw new ArgumentException("Invalid serializer type");
    }
    }
    private CubeGhostSerializer m_CubeGhostSerializer;
    }

    public struct EnableTrying intGhostSendSystemComponent : IComponentData
    {}
    public class Trying intGhostSendSystem : GhostSendSystem<Trying intGhostSerializerCollection>
    {
    protected override void OnCreate()
    {
    base.OnCreate();
    RequireSingletonForUpdate<EnableTrying intGhostSendSystemComponent>();
    }

    public override bool IsEnabled()
    {
    return HasSingleton<EnableTrying intGhostSendSystemComponent>();
    }
    }


    If I remove the Trying from the generated code it fixes the compiler errors.

    This is happening for the generated scripts : GhostSerializerCollection and and GhostDeserializerCollection
     
  2. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    The GhostCollectionAuthoringComponent has a NamePrefix field which will be used when generating the code.

    Make sure to remove any whitespaces from that and generate it again.
     
  3. RyancHaynes

    RyancHaynes

    Joined:
    Dec 8, 2018
    Posts:
    11

    Ah yea, thank you I did such and well.. it worked, why is it set to Trying Int though?