logo
down
shadow

OnEnable function from of ScriptableObject not being called


OnEnable function from of ScriptableObject not being called

By : Gofang
Date : November 21 2020, 11:01 PM
I wish this helpful for you For the OnEnable() function to be called while inheriting from ScriptableObject, you must call the CreateInstance() function from ScriptableObject class.
code :
[InitializeOnLoad]
public class MyWindow : ScriptableObject
{
    static string pathToScript;
    static MyWindow windowInstance;

    [MenuItem("Window/My Window")]
    static void Open()
    {
        Debug.Log("Open:" + pathToScript);

        //Do something with `pathToScript`

        if (windowInstance == null)
            windowInstance = ScriptableObject.CreateInstance<MyWindow>();

    }

    protected void OnEnable()
    {
        Debug.Log("Enabled!");
        var script = MonoScript.FromScriptableObject(this);
        pathToScript = AssetDatabase.GetAssetPath(script);
    }
}
[InitializeOnLoad]
public class MyWindow : ScriptableObject
{
    static string pathToScript;

    [MenuItem("Window/My Window")]
    static void Open()
    {
        Debug.Log("Open:" + pathToScript);

        //Do something with `pathToScript`
    }

    protected void OnEnable()
    {
        Debug.Log("Enabled!");
        var script = MonoScript.FromScriptableObject(this);
        pathToScript = AssetDatabase.GetAssetPath(script);
    }
}
public class Test : MonoBehaviour
{
    public MyWindow myWindow;
    public void OnEnable()
    {
        if (myWindow == null)
            myWindow = Object.FindObjectOfType<MyWindow>();

        if (myWindow == null)
            myWindow = ScriptableObject.CreateInstance<MyWindow>();
    }
}


Share : facebook icon twitter icon
Bukkit NullPointerException onEnable()

Bukkit NullPointerException onEnable()


By : user2745016
Date : March 29 2020, 07:55 AM
this one helps. I did it!
Instead of setting the RemoveEntities variables, I told the RemoveEntities class to find the variables in the EntityManager class.
Error in unity(Script Inspector 3): GetBool is not allowed to be called from a ScriptableObject constructor

Error in unity(Script Inspector 3): GetBool is not allowed to be called from a ScriptableObject constructor


By : Ketul Gupta
Date : March 29 2020, 07:55 AM
Hope that helps Niresh, the version of Script Inspector 3 you are using is way too old for newer versions of Unity. In July 2016 Unity released version 5.4 and Script Inspector 3 got upgraded to version 3.0.13 to support those changes. Just update your copy from Unity Asset Store to the latest released Si3 version (currently 3.0.17) and it will just work fine.
Unity3D: void OnEnable() is called Unpredictably in Editor Mode

Unity3D: void OnEnable() is called Unpredictably in Editor Mode


By : Kiwam153
Date : March 29 2020, 07:55 AM
wish helps you MonoBehaviour.OnEnable() is called when the script component is actived. UnityEngine.UI.Image inherits from MonoBehaviour, so there should be no difference. You may need to have a look at Execution Order of Event Functions.
If you want your MonoBehaviour called by the editor, you should add a ExecuteInEditMode attribute to your class.
Call method before ScriptableObject's OnEnable

Call method before ScriptableObject's OnEnable


By : EKissler
Date : March 29 2020, 07:55 AM
Hope this helps Yes, you can use Awake(), which is called on scripts before OnEnable.
Note that these messages work slightly differently on ScriptableObjects than on MonoBehaviours - there's a good thread over at Unity's forums discussing ScriptableObject events.
Custom nifi processor OnEnable anotation is not being called

Custom nifi processor OnEnable anotation is not being called


By : yashi
Date : March 29 2020, 07:55 AM
it helps some times You probably want @OnScheduled which is called when you start the processor, then you would close connections in @OnStopped.
Another option is to lazily create the connection in onTrigger by checking if the connection is null, and if it is then initialize it.
Related Posts Related Posts :
  • Timer not starting
  • Selecting elements inside UWP-Hub
  • How to setup Azure Notification Hub in C# backend
  • CollectionDataContract with the extra property
  • Modifying the resultant Executing assembly path c#
  • AutoGenrate the code
  • how to assign backspace as back key
  • Show message and Reload page in C# asp.net webform
  • How to allow only first punctuation mark in string with different marks sequence between words
  • Restore maximzed state on secondary monitor
  • MVC.Net Open a file in a new window instead of downloading
  • C# How to delete every character after something on every line
  • Entity Framework 6 stored procedure call resultset decimal value is 0
  • Accessing Non Static Method from another page
  • Random number generator, pick 3 in a range, returns group of 2 in some iterations
  • EPPlus number format
  • mvc razor does not redirect to url after action
  • Using SUM(Total). SQL statement works fine in PHP+MySQL
  • Regex - How to capture an arbitrary string appearing anywhere in a known string?
  • Passing parameters to stored procedure using EF6
  • How to find string with punctuation at the end
  • Bind a linkedlist to a datagridview
  • Entity Framework: determine sides of foreign key relation
  • C# Join Clause with association table
  • How to use HttpClient without async
  • Rectangle contains Point returns false
  • Encoding / Decoding 14-bit from Int to Hex and vice versa
  • Why getting error Cannot deserialize the current JSON object?
  • C# I can't print variable text in other Form
  • Issue on Getting Date Name of Day, Month, Date and Year
  • Entity Framework : update user fails
  • Calling a function from other script in Unity
  • How to add Roles to Windows Authentication in ASP.NET Core
  • Error installing Xamarin.Auth from NuGet
  • create relation between two tables
  • Discord.NET await outside command
  • Does the storage of PCM data of Mp3 File depends on Big Endian and little Endian?
  • XML data filtering and searching
  • Highlight selected tab in Xamarin Forms UWP
  • I have made a notifyicon in my application but i want to make it stay in system tray when application closes
  • What is the C# regex format to match +- signs or space?
  • Access controller data from ViewModel
  • How to do not allow whitespace before specific punctuation mark
  • Largest sum of upper-left quadrant of matrix that can be formed by reversing rows and columns
  • Find the 10001st prime
  • avalon dock auto hide crash application
  • Why List<T>.RemoveRange(index, count) changes value before index?
  • Where to call .AsParallel() in a LINQ query
  • How include another field on the Group BY
  • How do i make this button's event handler to add multiple values into an array?
  • Passing information to website
  • Seperation of db connection in seperate class file doesn't work
  • How to make C# application responsive
  • Equation to 2d points
  • Collision via Character Controller doesn't work
  • NullReferenceException accessing Workbook Cells with NPOI
  • Unity extend SceneManager class
  • c# Working with Strings
  • Where can I find a working example for Serial/UART reading with Universal Windows Application?
  • A way to store a method in a variable?
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com