Search Unity

No Cinemachine Script Defines / Symbols?

Discussion in 'Cinemachine' started by sxnorthrop, Apr 11, 2020.

  1. sxnorthrop

    sxnorthrop

    Joined:
    Sep 29, 2014
    Posts:
    43
    Given that Cinemachine allows developers to integrate custom code and features, why are there no default scripting symbols for cinemachine (e.g. #define CINEMACHINE)?

    Let's say I decided to create an integration with Cinemachine and my own camera system. Without any defined symbols, end users would need to take an extra step of deleting files, or unchecking the folder for scripts in an asset import, just so they don't get errors.

    This to me seems like quite an oversight. Maybe we could see such a thing in a future release? It's only 1 line of code, and it makes a world of a difference to developers like me.

    Thanks, hope to hear back.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I'm not sure I understand what you're asking for. Are you suggesting that in some Cinemachine file we add a #define CINEMACHINE? If we do, that define will only be visible within the Cinemachine assembly, so it won't help you.
     
  3. sxnorthrop

    sxnorthrop

    Joined:
    Sep 29, 2014
    Posts:
    43
    Okay, wasn't aware that that would occur with that approach, however I don't believe that invalidates my suggestion. To clarify, I'm asking if it's possible for you to implement a scripting symbol (see below) that developers can use to manage their project dependencies?

    upload_2020-4-18_13-12-16.png

    Example:
    Lets say I'm making a camera controller system, at the moment if I want to integrate cinemachine I have to create a separate unity package so that users without cinemachine don't receive compilation errors when using my camera controller system. However, if you included a script define symbol, I could use utilize that during initialization and/or at runtime to dynamically manage my dependencies without users needing to do any "extra" steps.

    Hope this makes sense! Thanks!

    EDIT:
    After thinking a bit more about it, I could technically manage this on my own by adding a custom symbol when a user clicks some button or checkbox, however I feel it would be nicer for cinemachine itself to provide this out of the box. :)
     

    Attached Files:

    Last edited: Apr 18, 2020
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    You can do this on your side through an assembly definition (asmdef) asset.

    If you create an asmdef asset, you would add a dependency to Cinemachine (via the assembly definition references list). Then you use the version defines list in your asmdef to let Unity generate a define for you, that you can check against in your code.

    upload_2020-4-18_20-13-33.png

    If the
    com.unity.addressables
    package is present and its version is greater or equal 0.0.0, then Unity sets the specified
    ADDRESSABLES_PRESENT
    symbol that I can use in my package code.
     
    Chrisdbhr, Gregoryl and sxnorthrop like this.
  5. sxnorthrop

    sxnorthrop

    Joined:
    Sep 29, 2014
    Posts:
    43
    Holy cow, that's awesome! Thanks man. Question = answered :D
     
    Peter77 likes this.