errors/warnings in generated scriptable objects in unity

Mon 7. Aug 2017, 18:12

the generated code for the scriptable objects of type Entity is complaining. Whenever it serializes (which is almost every min since it happens at play time and refresh time).

this is generated in this case for a template in a entity.

Code: Select all
UnityException: ScriptableObject.ctor is not allowed to be called during serialization, call it from OnEnable instead. Called from ScriptableObject 'Faction'.
See "Script Serialization" page in the Unity Manual for further details.
UnityEngine.ScriptableObject..ctor () (at C:/buildslave/unity/build/artifacts/generated/common/runtime/BaseClassBindings.gen.cs:461)
Articy.Unity.ArticyObject..ctor ()
Articy.Eyes_In_Shadow.Entity..ctor () (at Assets/ArticyContent/Generated/Entity.cs:50)
Articy.Eyes_In_Shadow.Faction..ctor () (at Assets/ArticyContent/Generated/Faction.cs:27)
Articy.Eyes_In_Shadow.Features.BasicCharacterFeature..ctor () (at Assets/ArticyContent/Generated/Features/BasicCharacterFeature.cs:31)


the offending generated code is

Code: Select all
        [SerializeField()]
        private PreviewImage mPreviewImage = new PreviewImage();
h3llye
 
Posts: 9
Joined: Wed 6. Mar 2013, 09:35

Re: errors/warnings in generated scriptable objects in unity

Tue 8. Aug 2017, 09:18

Hi h3llye,

that is indeed annoying and i will try to get rid of that, but first i need some more information.

What unity version are you using? What plugin version are you using? Can you show me the the generated code of those files shown in the log entry (Entity.cs, Faction.cs, BasicCharacterFeature.cs)?

Best regards

Nico
Nico Probst
Senior Software Engineer | Articy | LinkedIn
User avatar
[Articy] Nico Probst
Articy Staff
Articy Staff
 
Posts: 217
Joined: Wed 23. Nov 2011, 09:45
Location: Bochum

Re: errors/warnings in generated scriptable objects in unity

Wed 16. Aug 2017, 21:27

Code: Select all
// ------------------------------------------------------------------------------
//  <autogenerated>
//      This code was generated by a tool.
//      Mono Runtime Version: 2.0.50727.1433
//
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </autogenerated>
// ------------------------------------------------------------------------------

using System;
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
using Articy.Unity;
using Articy.Unity.Interfaces;

namespace Articy.Eyes_In_Shadow
{
   
   
    public class Entity : ArticyObject, IEntity, IPropertyProvider, IObjectWithColor, IObjectWithDisplayName, IObjectWithPreviewImage, IObjectWithText, IObjectWithAttachments, IObjectWithExternalId, IObjectWithShortId, IObjectWithPosition, IObjectWithZIndex, IObjectWithSize
    {
       
        [SerializeField()]
        private ArticyValueArticyModelList mAttachments = new ArticyValueArticyModelList();
       
        [SerializeField()]
        private String mDisplayName;
       
        [SerializeField()]
        private Color mColor;
       
        [SerializeField()]
        private String mText;
       
        [SerializeField()]
        private String mExternalId;
       
        [SerializeField()]
        private Vector2 mPosition;
       
        [SerializeField()]
        private Single mZIndex;
       
        [SerializeField()]
        private Vector2 mSize;
       
        [SerializeField()]
        private PreviewImage mPreviewImage = new PreviewImage();
       
        [SerializeField()]
        private UInt32 mShortId;
       
        public List<ArticyObject> Attachments
        {
            get
            {
                return mAttachments.GetValue();
            }
            set
            {
                mAttachments.SetValue(value);
            }
        }
       
        public String DisplayName
        {
            get
            {
                return mDisplayName;
            }
            set
            {
                mDisplayName = value;
            }
        }
       
        public Color Color
        {
            get
            {
                return mColor;
            }
            set
            {
                mColor = value;
            }
        }
       
        public String Text
        {
            get
            {
                return mText;
            }
            set
            {
                mText = value;
            }
        }
       
        public String ExternalId
        {
            get
            {
                return mExternalId;
            }
            set
            {
                mExternalId = value;
            }
        }
       
        public Vector2 Position
        {
            get
            {
                return mPosition;
            }
            set
            {
                mPosition = value;
            }
        }
       
        public Single ZIndex
        {
            get
            {
                return mZIndex;
            }
            set
            {
                mZIndex = value;
            }
        }
       
        public Vector2 Size
        {
            get
            {
                return mSize;
            }
            set
            {
                mSize = value;
            }
        }
       
        public PreviewImage PreviewImage
        {
            get
            {
                return mPreviewImage;
            }
            set
            {
                mPreviewImage = value;
            }
        }
       
        public UInt32 ShortId
        {
            get
            {
                return mShortId;
            }
            set
            {
                mShortId = value;
            }
        }
       
        protected override void CloneProperties(object aClone)
        {
            Entity newClone = ((Entity)(aClone));
            newClone.Attachments = new List<ArticyObject>();
            int i = 0;
            for (i = 0; (i < Attachments.Count); i = (i + 1))
            {
                newClone.Attachments.Add(((ArticyObject)(Attachments[i].CloneObject())));
            }
            newClone.DisplayName = DisplayName;
            newClone.Color = Color;
            newClone.Text = Text;
            newClone.ExternalId = ExternalId;
            newClone.Position = Position;
            newClone.ZIndex = ZIndex;
            newClone.Size = Size;
            newClone.PreviewImage = PreviewImage;
            newClone.ShortId = ShortId;
            base.CloneProperties(newClone);
        }
       
        public override bool IsLocalizedPropertyOverwritten(string aProperty)
        {
            return base.IsLocalizedPropertyOverwritten(aProperty);
        }
       
        #region property provider interface
        public override void setProp(string aProperty, object aValue)
        {
            if ((aProperty == "Attachments"))
            {
                Attachments = ((List<ArticyObject>)(aValue));
                return;
            }
            if ((aProperty == "DisplayName"))
            {
                DisplayName = System.Convert.ToString(aValue);
                return;
            }
            if ((aProperty == "Color"))
            {
                Color = ((Color)(aValue));
                return;
            }
            if ((aProperty == "Text"))
            {
                Text = System.Convert.ToString(aValue);
                return;
            }
            if ((aProperty == "ExternalId"))
            {
                ExternalId = System.Convert.ToString(aValue);
                return;
            }
            if ((aProperty == "Position"))
            {
                Position = ((Vector2)(aValue));
                return;
            }
            if ((aProperty == "ZIndex"))
            {
                ZIndex = System.Convert.ToSingle(aValue);
                return;
            }
            if ((aProperty == "Size"))
            {
                Size = ((Vector2)(aValue));
                return;
            }
            if ((aProperty == "PreviewImage"))
            {
                PreviewImage = ((PreviewImage)(aValue));
                return;
            }
            if ((aProperty == "ShortId"))
            {
                ShortId = ((UInt32)(aValue));
                return;
            }
            base.setProp(aProperty, aValue);
        }
       
        public override Articy.Unity.Interfaces.ScriptDataProxy getProp(string aProperty)
        {
            if ((aProperty == "Attachments"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(Attachments);
            }
            if ((aProperty == "DisplayName"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(DisplayName);
            }
            if ((aProperty == "Color"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(Color);
            }
            if ((aProperty == "Text"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(Text);
            }
            if ((aProperty == "ExternalId"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(ExternalId);
            }
            if ((aProperty == "Position"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(Position);
            }
            if ((aProperty == "ZIndex"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(ZIndex);
            }
            if ((aProperty == "Size"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(Size);
            }
            if ((aProperty == "PreviewImage"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(PreviewImage);
            }
            if ((aProperty == "ShortId"))
            {
                return new Articy.Unity.Interfaces.ScriptDataProxy(ShortId);
            }
            return base.getProp(aProperty);
        }
        #endregion
    }
}



this is some of the generated code.

the plugin version is v1.1.0.31744
h3llye
 
Posts: 9
Joined: Wed 6. Mar 2013, 09:35

Return to articy:draft Unity Importer

Who is online

Users browsing this forum: No registered users and 59 guests

Who We Are
Contact Us
Social Links