Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Crouching-Tuna · Jan 04, 2015 at 12:59 PM · buildscriptableobject

Can not load ScriptableObject

Hi,

The problem I'm having only happens in build. In editor it works fine.

So I have several scriptableObjects, here's one of the class:

 [System.Serializable]
 public class Affected{
     public string effect;
     public GameObject source;
     public float num;
     public int dur;
     public float timer = 0f;
     public Affected(string theEff, float theNum, float theDur, GameObject theSource){
         effect = theEff;
         source = theSource;
         num = theNum;
         dur = Mathf.CeilToInt(theDur);
     }
 }
 
 [System.Serializable]
 public class SkillInstance{
     public string name = "";
     public float variance = 1f;
     public bool physical = false;
     public SkillInstance(string n, float p, bool pm){
         name = n;
         variance = p;
         physical = pm;
     }
 }
 
 [System.Serializable]
 public class Skill{
     // The type of skill, with list of effect
 
     public string name;
     public string desc;
     public AimType aimType = AimType.Self;
     public CastType castType = CastType.Click;
     public ReleaseType release = ReleaseType.Apply;
     public SpiritType element = SpiritType.Fire;
     public List<string> effects = new List<string>();
 
     //public float scale = 0f;        // Various effect depending on OnHit
     //public Entity source = null;
 }



I populated the scriptableObject that I made. Then in a Manager Gameobject, I have public SkillDatabase which I assigned the scriptable object there. Somewhere in the manager I have:

     if(!skillDB)
             Debug.LogError ("SkillDB missing");
             if(skillDB)
             foreach(Skill sk in skillDB.skills){
                 Formula.allSkill.Add(sk.name, sk);
             }
 


So Formula.allSkill (a static Dictionary) will have that now(maybe this is unnecessary. I just want all the skills to be in a Dictionary form). Anyways, things works in editor. In build, however, the error could either be - a script behaviour has a different serialization layout when loading - Script attached to in scene '' is missing or no valid script is attached. UnityEditor.HostView:OnGUI() webplayer - An error that says a file is corrupt. Try removing that and restart Unity.

I've tried several things like putting the scriptableObjects in Resources folder, and have skillDB = Resources.Load("SkillDB") as SkillDatabase;

The scriptableObject is always null.

The thing is, all the scriptableObjects are always having a "missing script" error in the editor, right after I just launch Unity. But pressing play once, and stop, will make the scriptableObjects seem to "remember" again the values in it. I really don't know what's causing this. So, maybe in build, this is what's actually happening. All the scriptableObjects are having the "missing script" error.

Anyone know what's happening?

The only thing I'm thinking might cause this is because I put some #if UNITY_EDITOR, but I only put these in scripts that deals with creation of the scriptableObjects itself(just to create the asset). So, I don't think this is what's causing it...

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Distribute terrain in zones 3 Answers

PC Build is not behaving like my android and webgl builds 1 Answer

How to make game moddable? 1 Answer

Scriptable Object in Editor vs in Build 0 Answers

Resource.LoadAll Not Working On Child Assets In Stand Alone Build 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges