• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mundizor · Apr 05, 2014 at 04:58 PM · prefabshierarchy

Creating hierarchy of objects without prefabs

Im coming to Unity from programming in C++ and C# so I know Object oriented programming but not prefabs.

I have created a baseclass and some classes inheriting from this class. Nothing fancy at all. None of theese classes uses MonoBehaviour. So my problem arises when I realised that my baseclass has to have a texture that it should render.

So first question: Can I have this baseclass have a texture that it can render on screen without needing to inherit from MonoBehaviour? If so, how?

As I cant find a way to do so I make the baseclass inherit from MonoBehaviour. Then another problem rises. When I create my objects I can no longer use the "New" keyword. I have to use instantiate(). When i use instantiate() I have to Instantiate an object and not a class.

Question Number 2: How do I create an object without the "new" keyword to use for instantiating?

The best way I can think of is to create a prefab and a public variable that inputs an object from the editor. Im very new to this part of "unity gamedeveloping". I dont like to drag stuff in the editor, it seems redundant and slow. And if I have to do it this way it will take a while to make every object take an input in the form of another object. Thats alot of drag n drop.

But to drag a script into a prefab it apparently needs to be MonoBehaviour so then everything will have to inherit from that. This also seems reduntant when only the baseclass needs the functionality of MonoBehaviour.

Question number 3: The Unity developers are clearly very experienced developers(more than me atlest) so Im assuming there is a positive side to this and I would like to know some of them.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how to replace multiple game objects with different transform component with same prefab? 1 Answer

Why do prefabs have redundant transforms? 0 Answers

Children of prefab disappear in Hierarchy when prefab parent is clicked,Children of prefab disappear in Hierarchy when prefab is clicked 2 Answers

Hierarchy index of prefab change when putting in into an array? 1 Answer

A question about Standard assets(Mobile)! 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges