Forum rules - please read before posting.

Error on 'Hold Object'

AC 1.62.5, Unity2017.4.2:
New to me:

Can't add component 'MonoBehaviour' to mH_BookSet1_Book1 because the game object is a generated prefab and can only be modified through an AssetPostprocessor.
UnityEngine.GameObject:AddComponent()
AC.Action:FieldToID(GameObject, Int32) (at Assets/AdventureCreator/Scripts/ActionList/Action.cs:736)
AC.ActionCharHold:ShowGUI(List`1) (at Assets/AdventureCreator/Scripts/Actions/ActionCharHold.cs:147)
AC.ActionListEditorWindow:NodeWindow(Int32) (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:665)
UnityEditor.EditorWindow:BeginWindows()
AC.ActionListEditorWindow:NodesGUI(Boolean) (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:876)
AC.ActionListEditorWindow:OnGUI() (at Assets/AdventureCreator/Scripts/ActionList/Editor/ActionListEditorWindow.cs:341)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Comments

  • Can you provide a little more detail into what you did that caused the error message?  It's not clear if this is a bug, or the warning is geniune advice.

    What exactly are you assigning in your Character: Hold object Action's Object to hold field?  Relevant screenshots would help a lot.
  • I was trying to assign a prefab from the project window as the Object to hold. I assigned the character's hand bone as required -- the instantiation was supposed to be part of a conversation, so an ActionList node: I give her a book and it appears in her hand. 
    Perhaps instantiation is not even allowed in this case. So does it only work with in-scene gameobjects? It does work when the book is already in the Hierarchy.

    I can still give you a screenshot if more info is needed.
  • It should instantiate it if the assigned object is not present in the scene, though it's generally easier to have it in the scene beforehand.

    The error is not to do with the running of the Action, however - it's with the Action's GUI, which is trying to add a Constant ID component to the prefab (necessary for saving links between assets and scene objects).

    Assigning a prefab works OK for me in the AC/Unity versions you described, but I don't know what Unity's referring to when it says "generated prefab".  Is this some kind of special prefab type you've made?  Does the error show when assigning a prefab from e.g. the Demo game's folder?
  • Now I'm also getting a somewhat similar GUI error when trying to assign Look/Use Actions to Inventory items. Hasn't happened before:



    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.GUILayoutUtility.BeginLayoutGroup (UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options, System.Type layoutType) (at C:/buildslave/unity/build/Runtime/IMGUI/Managed/GUILayoutUtility.cs:296)
    UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUIContent content, UnityEngine.GUIStyle style, UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7787)
    UnityEditor.EditorGUILayout.BeginHorizontal (UnityEngine.GUILayoutOption[] options) (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:7767)
    AC.ActionListAssetMenu.AssetGUI (System.String label, AC.ActionListAsset actionListAsset, System.String api, System.String defaultName) (at Assets/AdventureCreator/Scripts/ActionList/ActionListAsset.cs:233)
    AC.InventoryManager.ItemsGUI () (at Assets/AdventureCreator/Scripts/Managers/InventoryManager.cs:364)
    AC.InventoryManager.ShowGUI () (at Assets/AdventureCreator/Scripts/Managers/InventoryManager.cs:147)
    AC.AdventureCreator.OnGUI () (at Assets/AdventureCreator/Scripts/Managers/Editor/AdventureCreator.cs:244)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:295)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:288)
    UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:255)

  • edited May 2018
    It's not related so far as I can tell.  Are you assigning ActionList assets into the field manually, or clicking "Create" to automatically generate them?

    Does it prevent you assigning anything, or does it not have any effect?
  • Update: Recreated.  I believe it's a Unity Editor issue, but can be safely ignored - assuming the field itself is being properly assigned for you as it is for me.
  • I always generate them with "Create".
    It does allow me to assign stuff, it's just the frequency and length of the error message that's concerning.
     
    Thanks for looking into it!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.