Y
Y
Yugg02022-03-29 15:58:04
Nginx
Yugg0, 2022-03-29 15:58:04

How to implement a given ScriptableObject function in Unity?

There is a code (just an example):

using UnityEngine;

public enum Weapon
{
    Sword,
    Shield
}

[CreateAssetMenu(fileName = "Test", menuName = "Unity Test", order = 0)]
public class Test : ScriptableObject
{
    [SerializeField] private Weapon weapon;

    public int damage;
    public int defense;
}


I need that when "Sword" is selected in "Weapon" I only see "damage" in the editor.
And if "Shield" is selected, then "defense".

As shown in screenshots:
624301c2437fb949919959.png
624301edad6fc860055762.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
John Doe, 2016-07-23
@Homchenkokostya

Well, I basically went the other way:

rewrite ^/news/social/(.*)$ /news/social/?date=$1 break;
rewrite ^/news/(.*)$ /news/?date=$1 break;

It's just that all the data is in one parameter, and parsing them is already in php. And the main fact is that the main page /news/ should come last, otherwise /news/social/ will not work correctly, namely /social/ will be defined as a parameter, not as an address.

F
freeExec, 2022-03-29
@freeExec

Option 1: You write your own custom inspector, where you completely control what and how to display on the screen, when and what to save when changing.
Option 2: You create only one variable Valueand further process it in the code depending on the type.

F
Farawa, 2022-03-29
@Farawa

https://docs.unity3d.com/Manual/editor-CustomEdito...
you make a switch in the editor script, in which you choose which fields to draw for each weapon

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question