Search Unity

Question Component not working as component

Discussion in 'Scripting Dev Blitz Day 2023 - Q&A' started by DevDunk, Feb 23, 2023.

  1. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,058
    I would love to be able to inherit from the component class and then add the script to gameobjects as a component. No update, etc, just it being liked to a gameobject. Sadly this is not how this works and you need to inherit from MonoBehavior for this.

    Component has the basic functionality needed, so why isn't this a feature for more lightweight components?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,923
    Would it make a major performance difference? Unity already keeps track of what components do and don't have certain messages. Unity won't call a message if it knows it doesn't implement said message.
     
  3. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,058
    I was thinking it could be better for memory. If that's not the case then never mind haha