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 /
avatar image
0
Question by lukegothic · Feb 09, 2018 at 12:29 PM · scriptableobjecteffectcardpolymorphism

Card Game, cards as ScriptableObject, card effects as ScriptableObjects, effects have different parameters. How to make an inspector UI support this structure?

As the title says, I'm developing a card game in which I want the cards to be modelled as ScriptableObjects, and their "card is played" effects as ScriptableObjects too. The problem is that those Effects are polymorphic and each one has it's own parameters.

alt text

I would want the card effects to be displayed in the inspector as either [1] or [2], so that I can dinamically add effects to the list and also configure the effect parameters.

alt text

The closest I've come is by creating each effect asset with the parameters set, but I want the parameters to be configurable on the card and not on the effects (imagine having to have an effect asset for 1 damage, 2 damage, 3 damage... and so on)

https://image.prntscr.com/image/14mrXRjBS4iiMFhqqIgtiw.png


I'm assuming that either I have approached this problem in the wrong way or that I have made a mistake (or many). What should I change and implement to either accomplish [Inspector 1] or [Inspector 2]?

model.png (14.7 kB)
inspectors.png (65.1 kB)
Comment
Add comment · Show 1
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 lukegothic · Feb 10, 2018 at 08:23 AM 0
Share

/u/JimWest on reddit pointed out a solution on the problem readily available to download: https://heavens-vault-game.tumblr.com/post/162127808290/inline-scriptableobject-editing-in-unity Just tested it and works like a charm.


On the other hand, after trying the solution, I found that my approach on this problem was wrong, I can modify the ScriptableObject Effect in the inspector, but multiple instances of a Card Asset sharing an Effect Asset can't have different values on the effect's variables. So I can't just have a DamageEffect instance, because changing the values from one card changes the values on every card.

In my case I've changed the approach to the problem so the parent Effect is an Interface now, and I'm currently working on having it to show on the inspector.

2 Replies

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

Answer by lukegothic · Feb 10, 2018 at 08:25 AM

/u/JimWest on reddit pointed out a solution on the problem readily available to download: https://heavens-vault-game.tumblr.com/post/162127808290/inline-scriptableobject-editing-in-unity Just tested it and works like a charm.

Comment
Add comment · 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
0

Answer by FDT · Feb 09, 2018 at 03:55 PM

I dont know if this is suited for your example, but I resolved a similar situation by doing this: I have a singleton manager in the scene, with scriptableobjects items added to a list on this manager.

In a x class inspector, no matter where it was used (scriptableobject in project, gameobject in scene, etc) i have some class variables (let's say ItemData) with a property drawer, that it have to be used to input a string that is an ID from the same scriptableobject items added to the singleton. I resolved it by detecting the selected scene object, and if it is the singleton, the drawer for the ItemData shows a dropdown list with the names of the items added to the singleton, and if not the case, it shows the inputfield to enter it by hand. I take care also of not doing this writtable in runtime, detect when the focus changes in the selected gameobject and some other edge situations. I hope this gaves you an idea of what to do.

Comment
Add comment · 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

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

77 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

Related Questions

How to access derived class members from base class type 1 Answer

How to make a deep copy of a list of ScriptableObject derived types? 1 Answer

Polymorphism with generic ScriptableObjects? 1 Answer

Polymorphic Scriptable Object 2 Answers

How to Keep Track of ScriptableObject Coroutine Durations? 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