tayabeijing.blogg.se

Assign script to created asset from scriptable
Assign script to created asset from scriptable










assign script to created asset from scriptable
  1. ASSIGN SCRIPT TO CREATED ASSET FROM SCRIPTABLE HOW TO
  2. ASSIGN SCRIPT TO CREATED ASSET FROM SCRIPTABLE FULL
  3. ASSIGN SCRIPT TO CREATED ASSET FROM SCRIPTABLE DOWNLOAD

menuName: The name of the asset as it appears in the Asset Menu.fileName: The default name when the asset is created.But before you can create these implementations, you will need to add your ScriptableObject to the Asset Menu.Īdd your ScriptableObject to the Asset Menu by giving the SwordData class the following attribute: This will let you set the values in the editor without giving access to the variable from other scripts.Įach sword will need it’s own unique implementation of the SwordData ScriptableObject. In Unity, the SerializeField attribute allows you to have private script variables that are exposed in the Inspector. attackDamage: An int to hold the attack damage of the sword.goldCost: An int to hold the gold cost of the sword.

assign script to created asset from scriptable

  • icon: A sprite to hold the icon of the sword.
  • description: A string to hold the description of the sword.
  • swordName: A string to hold the name of the sword.
  • Instead, it will be treated like any other common asset that can be created, similar to creating a prefab, scene or material.įill this script with some serialized fields that will contain all the data, corresponding with the information displayed on the Sword Merchant UI. This action tells Unity that you still want to use Unity features and methods, like a typical MonoBehaviour, but you’ll no longer need to put this script onto a GameObject. Public class SwordData : ScriptableObject Inside this class, start by deriving from ScriptableObject instead of MonoBehaviour: This class will be used as a container for all the sword data that will display in your Sword Merchant shop. Under the Scripts folder, create a new script called SwordData. It’s time to make your first ScriptableObject!
  • Sword Prefabs: Contains a prefab of every sword in the Sword Merchant scene.įirst, make sure you are in the Sword Merchant scene.
  • Sword Icons: Contains thumbnails of each individual sword.
  • Scripts: Currently houses one empty script, but you’ll add more during this tutorial.
  • Scenes: Contains the Sword Merchant scene that you’ll occupy for the entirety of this tutorial.
  • _Setup: For this tutorial, you won’t need to go into this folder at all.
  • You should see the following folder created as part of the starter project setup:

    ASSIGN SCRIPT TO CREATED ASSET FROM SCRIPTABLE DOWNLOAD

    Next, extract the download to a location of your choosing and open up the Scriptable Object Tutorial-Starter project in Unity. Start by downloading the materials you’ll need using the Download Materials link at the top or bottom of this tutorial. If you need to sharpen your Unity skills, check out some of our other Unity tutorials.

    ASSIGN SCRIPT TO CREATED ASSET FROM SCRIPTABLE HOW TO

    You should know how to edit code in a code editor and have a basic knowledge of C#. There are 333 methods atm.Note: This tutorial assumes you know your way around the Unity editor. There are number of different methods, and to get list of them type: editor._hooks.

    ASSIGN SCRIPT TO CREATED ASSET FROM SCRIPTABLE FULL

    Or to get full JSON representation of it: var json = asset.json() Įntities, Assets, Scene Settings and few other bits in editor are all observer objects. To get lets say file size: var size = asset.get('file.size') So to change lets say name of it: t('name', 'name from script') Everything in editor is bound to its changes, so changing that object will be saved on server, updates ui, viewport, history and other relevant bits. Object Observer - is an interface to set/get data to. And sometimes returns results.įor example getting asset data object: var asset = editor.call('assets:get', 42) So main way to do something is using editor.call(method) - this calls some function, with arguments after name if needed. This provides failure tolerant code execution. You could have noticed that editor.js is not minified, but only concatenated, so you can have a peek inside.Įditor uses a messaging approach to communicate between parts instead of interfaces. It is just not cleared up and not documented.

    assign script to created asset from scriptable assign script to created asset from scriptable

    But it is something we will have to address somewhere in the future.īut! there is an API in editor right now, it is not hidden and not minified from users. Hi had ideas and plans long ago to work on Plugin system.












    Assign script to created asset from scriptable