Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 AliveDevil · Feb 10, 2013 at 03:00 PM · editorvariable

Class Reference in Editor not working

Hey,

I didn't really knew how to call the question or whatever this is. I have a script called "DebugSpawner" - some script to spawn some items in the environment and two additional script called "SpawnerScript" and "DebuggingSpawner".

You may know what I want to do but let me tell you :D

The spawner has some properties to be filled. Things like

public GameObject SpawnItem;
public SpawnerScript SpawnScript;
public float SpawnTime = 1500;
public float TimeRandom = 5;
public float Radius = 10;
public float PlayerRadius = 150;
Basically there is no problem without the public SpawnerScript SpawnScript; this really doesn't want to work like I want it to work.

If I'm assigning a script through the editor which inherits from SpawnerScript the property keeps the value of "None (SpawnerScript)".

My SpawnerScript is like

public abstract class SpawnerScript : MonoBehaviour {
}

The DebuggingSpawner looks like

public class DebuggingSpawner : SpawnerScript {
    void Update () {
        Vector2 randPos = Random.insideUnitCircle;
        gameObject.transform.position += new Vector3 ( randPos.x * 5, 0, randPos.y * 5 );
    }
}

Some images to show you what I'm talking about. There you see that I'm able to select the right script but this is what is happening:

Assign Script to Script

It keeps the value of "None":

Result of assign

Any help for this or how I can fix it?

debugspawner.png (49.0 kB)
debugeditor.png (10.2 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by flaviusxvii · Feb 10, 2013 at 04:32 PM

Your DebuggingSpawner script has to be attached to a GameObject. You can create an empty game object, attach your script to it, then it'll be accepted in that "SpawnerScript" field. Make it a prefab if you want to use it scene to scene.

Comment
Add comment · Show 4 · Share
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
avatar image AliveDevil · Feb 10, 2013 at 04:40 PM 0
Share

a bit confusing that I can't add a blank script to another script but it's working now. Thanks.

avatar image Bunny83 · Feb 10, 2013 at 04:50 PM 0
Share

You have to understand the difference between a Script which is a class and an instance of that class. A class is just the "blueprint" of that object. It's like you try to drive with the blueprints of a B$$anonymous$$W. You have to build one before you can use it.

A lot people seems to miss this little but important thing about OOP.

avatar image AliveDevil · Feb 10, 2013 at 04:52 PM 0
Share

okay, OOP is not that problem but I'm new to Unity and have to learn these things from scratch.. It's a huge difference between the "normal" C# and this Unity thing.

avatar image flaviusxvii · Feb 10, 2013 at 04:56 PM 0
Share

I just pictured The Stig sitting on 1:1 scale B$$anonymous$$W blueprints making "vroom vroom" sounds and leaning into imagine corners.

It's a great analogy though. In OO, a class is just a schematic, and objects are the realization of that. Unity takes it a bit further with the $$anonymous$$onoBehavior class. A script that derives from $$anonymous$$onoBehaviour implicitly fits into a bigger picture of a GameObject.

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.

Follow this Question

Answers Answers and Comments

11 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

Related Questions

Script variable 1 Answer

Declaring animations on a script in the editor 1 Answer

Variables not visible in editor but accessible from other scripts 2 Answers

customization of variables in script for in Editor? 2 Answers

Fastest way to instantiate and move multiple game objects in the editor 3 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