CS7036 error is displayed when adding a custom class A that

Discussion and help for Easy Save 3
Post Reply
hexclare
Posts: 2
Joined: Tue Apr 28, 2020 8:51 am

CS7036 error is displayed when adding a custom class A that

Post by hexclare »

When I add a custom class to ES3 Types, I get a CS7036 error.
ES3Types added a custom class B containing List<Custom Class A> with custom class A as its type.
In ES3 Window, the message
This type has no public rapameterless constructors.
To support this type you will need to modify the ES3Type script to use a specific constructor instead of the parameterless constructor.
is displayed, and I tried to set an appropriate value for the argument, but I can't add a custom class A as an argument.
Assets\Easy Save 3\Types\ES3Type_Map.cs(45,32): error CS7036: There is no argument given that corresponds to the required formal parameter 'configName' of 'Map.Map(string, string, List<Node>, List<Point>)'

Code: Select all

using System;
using UnityEngine;

namespace ES3Types
{
    [UnityEngine.Scripting.Preserve]
    [ES3PropertiesAttribute("bossNodeName", "configName")]
    public class ES3Type_Map : ES3ObjectType
    {
        public static ES3Type Instance = null;

        public ES3Type_Map() : base(typeof(Map.Map)) { Instance = this; }

        protected override void WriteObject(object obj, ES3Writer writer)
        {
            var instance = (Map.Map)obj;

            writer.WriteProperty("bossNodeName", instance.bossNodeName, ES3Type_string.Instance);
            writer.WriteProperty("configName", instance.configName, ES3Type_string.Instance);
        }

        protected override void ReadObject<T>(ES3Reader reader, object obj)
        {
            var instance = (Map.Map)obj;
            foreach (string propertyName in reader.Properties)
            {
                switch (propertyName)
                {

                    case "bossNodeName":
                        instance.bossNodeName = reader.Read<System.String>(ES3Type_string.Instance);
                        break;
                    case "configName":
                        instance.configName = reader.Read<System.String>(ES3Type_string.Instance);
                        break;
                    default:
                        reader.Skip();
                        break;
                }
            }
        }

        protected override object ReadObject<T>(ES3Reader reader)
        {
			var instance = new Map.Map("configName", "bossNodeName", );
            ReadObject<T>(reader, instance);
            return instance;
        }
    }

    public class ES3Type_MapArray : ES3ArrayType
    {
        public static ES3Type Instance;

        public ES3Type_MapArray() : base(typeof(Map.Map[]), ES3Type_Map.Instance)
        {
            Instance = this;
        }
    }
}
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: CS7036 error is displayed when adding a custom class A t

Post by Joel »

Hi there,

This error occurs because your Map class has no parameterless constructor. The easiest way to fix this is to add a parameterless constructor to your Map class.

Note that there is a mistake in your modification to the ES3Type. You don't appear to have finished this line of code?
var instance = new Map.Map("configName", "bossNodeName", );
Also according to the error message, the second parameter should be a List<Node> and the third parameter a List<Point>.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
hexclare
Posts: 2
Joined: Tue Apr 28, 2020 8:51 am

Re: CS7036 error is displayed when adding a custom class A t

Post by hexclare »

Thanks for the reply!
And I'm sorry.
I didn't know that overload existed in C#.
The problem was solved by doing the following

It has been changed as follows.
1.

Code: Select all

var instance = new Map.Map("configName", "bossNodeName", );
↓.
var instance = new Map.Map();
2. Create a constructor with no arguments in Map.cs
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: CS7036 error is displayed when adding a custom class A t

Post by Joel »

Glad that worked for you :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply