Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Oogalook · Jan 04, 2017 at 10:55 PM · javascriptscriptableobjectscriptable object

Scriptable Object Syntax in Javascript

Clarification: I can't figure out how to make scriptableObjects in Javascript. No examples are anywhere on the website- all the example code is in C#. Help!

Original message: Hey folks,

I'm trying to make some scriptable objects to contain variables and functions for different tools in my game. However, I can't find how I'm supposed to make 'em in Javascript so that my other Javascript scripts can see/interact with them. I made the desired scripts in C#, but none of my other scripts can see them of course.

I want to ask, once and for all, how do you make a javascript scriptable object? I found somewhere

class MyScriptableObject extends ScriptableObject{ }

So I wrote,

class ToolBehavior extends ScriptableObject{}

and hoped to use "extend" to use it as an abstract class, like this:

class WelderTool extends ToolBehavior{}

But this results in nothing; I can't plug either ToolBehavior nor WelderTool in as a ToolBehavior variable in the inspector. It doesn't want to be attached like a monobehavior either.

Halp! One working example code would do it!

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
0

Answer by Adam-Mechtley · Jan 08, 2017 at 11:37 AM

So is the problem that you have defined ScriptableObject classes in javascript, and you are not able to successfully use them with C# classes? If that's the case, the JavaScript classes must be compiled in an earlier pass than the C# ones. You may find this page in the documentation helpful.

Comment
Add comment · Show 2 · 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 Oogalook · Jan 08, 2017 at 05:08 PM 0
Share

Hey thanks for the reply.

The underlying problem is that I can't figure out how to make scriptableObjects in Javascript. All the examples on the website are for C#, but imitating those scripts doesn't work for my projects for several reasons. Any idea how to write a Javascript (.js) and tell it to be a scriptableObject ins$$anonymous$$d of a monoBehavior?

Thanks!

avatar image Adam-Mechtley Oogalook · Jan 09, 2017 at 07:35 AM 0
Share

So there is no special syntax requirement, but I guess I still don't understand what exactly is happening for you. The examples you provided work just fine for me.

Have you ensured that each class is defined in its own js file, and that the name of the file matches the name of the class defined in it? This is a general requirement for both cs and js classes in Unity, whether they extend $$anonymous$$onoBehaviour or ScriptableObject.

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

120 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 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 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 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 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 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

Buttons to Scriptable objects 2 Answers

How do I place a custom tile? 1 Answer

How do I create tiles that I can add scripts to, and have players interact with? 0 Answers

I need a clean way to “cast” cards in a card game in Unity? 0 Answers

Should i use scriptable objects to create an achievements system? 1 Answer


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