Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Singleton Design Pattern Feedback

Discussion in 'General Discussion' started by jpgordon00, Nov 7, 2021.

  1. jpgordon00

    jpgordon00

    Joined:
    Jan 9, 2021
    Posts:
    25
    Hello,

    I would like feedback on my newest repository, which provides Singleton's for C#. Like my last repository and post, this repository is focused on Singleton-like design patterns. However, since my last repository, I have studied the problem and feedback given and have made the following changes:

    - Type and BaseType properties are now of type 'object' and is no longer limited to just strings.
    - Singleton's can be instantiated and destroyed on command with the 'Instantiate' and 'Destroy' properties. These singleton's can access properties and override functions to determine when it is being constructed and destroyed.
    - Find, FindAll, Instantiate and Destroy properties all can type or base type as a filter. They can additionally use a given generic to search by both type and base type, or by just the base type.
    - Singleton's can use a Instance property by inheriting from the generic class 'InstanceSingleton'.

    I would love any constructive feedback on for my project.
    Thanks in advanced!
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,324
    You licensed your code under GPL3.

    That means that NOBODY will be able to use your code with unity engine, as they will be unable to comply with the license.
    upload_2021-11-7_9-58-26.png

    Please research what opensource licenses mean.
    -------
    Same thing applies to your last repository.

    "GPL" means "it is unusable in any unity project".
     
    stain2319 likes this.
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,531
    Add a [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] method to initialize your static data or it won't work when domain reloading is disabled.
     
    jpgordon00 likes this.
  4. jpgordon00

    jpgordon00

    Joined:
    Jan 9, 2021
    Posts:
    25
    I did not know that, thank you. What is the recommended open source for a project like mine, where I'd like the developer full personal and professional use?
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,324
    For a single file I'd use public domain or CC0 and possibly release it as a github gist.

    For more complex stuff, Apache license, ZLib license, BSD license, MIT license are good.


    GPL comes with nasty restrictions - using GPL code requires you to convert your whole project to GPL, and that's impossible when you're using unity, because unity is proprietary.
    LGPL is less nasty, because it allows dynamic linking, but that's not really usable with unity either, as normally you use statically linked code in unity project. Actually the point of LGPL is that user should be able to swap the library with their own version.