Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
This question was closed Aug 17, 2019 at 10:48 PM by darkal for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by darkal · Aug 17, 2019 at 09:50 PM · errorassetbundleinstanceassetdatabase

"Object reference not set to an instance of an object" but it is.

Code its self pretty basic issue is once i bake one bundle any other GMC can not be baked pops up error of


NullReferenceException: Object reference not set to an instance of an object BuildMod.OnGUI () (at Assets/Editor/BuildMod.cs:32)


Here is code I'm working with few friends on this as well if i figure out ill post my findings


 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEditor;
 
 public class BuildMod : EditorWindow
 {
     GMC GMC_Data;
 
     [MenuItem("Assets/Cook Mod")]
     static void BuildAllAssetBundles()
     {
         EditorWindow.GetWindow(typeof(BuildMod));
     }
 
     void ClearData()
     {       
         AssetDatabase.RemoveUnusedAssetBundleNames();
         EditorWindow.GetWindow(typeof(BuildMod)).Close();
     }
 
     private void OnGUI()
     {
         GMC_Data = EditorGUILayout.ObjectField(GMC_Data, typeof(GMC), true) as GMC;
 
         if (GMC_Data != null)
         {
             if (GUILayout.Button("Cook"))
             {
                 AssetImporter.GetAtPath("Assets/Mods/" + GMC_Data.Name + "/" + GMC_Data.Name + ".asset").SetAssetBundleNameAndVariant(GMC_Data.Name, "GMC");                
                 BuildPipeline.BuildAssetBundles("Assets/StreamingAssets/" + GMC_Data.name, BuildAssetBundleOptions.UncompressedAssetBundle, BuildTarget.StandaloneWindows64);
                 AssetImporter.GetAtPath("Assets/Mods/" + GMC_Data.Name + "/" + GMC_Data.Name + ".asset").SetAssetBundleNameAndVariant("", "");
                 ClearData();
             }           
         }
     }
 }

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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by darkal · Aug 17, 2019 at 10:48 PM

I was able figure it out I was using variable GMC.Name instead of GMC.name which is name of the asset by replace Name with name the issue has been fixed and now works everytime without issue.

Comment
Add comment · Share
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
avatar image
0

Answer by thehiveissocial · Aug 17, 2019 at 10:13 PM

Perhaps putting GMC_Data = EditorGUILayout.ObjectField(GMC_Data, typeof(GMC), true) as GMC; inside of the Start function instead of OnGUI function would work? I'm guessing the error is coming from that line of code I recommended to put in start since the other lines do a if not null check. I'm not really familiar with GUI but figured it wouldn't hurt trying to help.

Comment
Add comment · Show 2 · Share
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
avatar image darkal · Aug 17, 2019 at 10:32 PM 0
Share

No it has use the OnGUI as it creates a variable inside of a window same way as in the inspector everything works fine tell it runs


AssetDatabase.RemoveUnusedAssetBundleNames();

avatar image darkal darkal · Aug 17, 2019 at 10:33 PM 0
Share

And i require that part to remove the unused bundle names other wise they get messy

Follow this Question

Answers Answers and Comments

146 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 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 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 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 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 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

Error after building a bundle,Error while creating a bundle 0 Answers

An instance of type "x" is required to access non-static variable "y" 2 Answers

When looping through assetbundle assetdatabase how do you reference a material object 0 Answers

AssetBundle Error 1 Answer

The file 'MemoryStream' is corrupted! 6 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