Klasse PrefabAsset

java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.PrefabAsset

public final class PrefabAsset extends Asset
Represents a prefab. A prefab may consist of several meshes. You can prepare a prefab in Unity, so it may also contain custom materials (including custom shaders), lights, particle effects etc.
Supported file formats: zip, fbx, obj, stl, ply, 3mf, gltf
  • Methodendetails

    • loadFromGame

      public static PrefabAsset loadFromGame(String path)
      Loads a prefab from the game assets. This is quite efficient because the server doesn't have to send any data to the clients.
      To get the prefab asset paths of game items, you could check out the various tables in the definitions.db file (in Data/StreamingAsets/). Alternatively get the asset path from the Definitions via API.
      Parameter:
      path - the path to the game prefab.
      Gibt zurück:
      a new prefab asset instance.
      Example: Load pickaxe from game files using hard-coded path
      1PrefabAsset asset = PrefabAsset.loadFromGame("Models/Items/Pickaxe/pickaxe.prefab");
      2//do something with the asset

      Example: Load pickaxe from game files using definition
      1//Get item definition
      2Items.ItemDefinition itemDef = Definitions.getItemDefinition("pickaxe");
      3
      4//Get asset path (from variant 0)
      5String assetpath = itemDef.getVariant(0).assetpath;
      6
      7PrefabAsset asset = PrefabAsset.loadFromGame(assetpath);
      8//do something with the asset
    • loadFromAssetBundle

      public static PrefabAsset loadFromAssetBundle(AssetBundle bundle, String path)
      Loads a prefab from an AssetBundle.
      Parameter:
      bundle - the asset bundle you want to load the prefab from.
      path - the path in the asset bundle.
      Gibt zurück:
      a new prefab asset instance.
    • loadFromFile

      public static PrefabAsset loadFromFile(String file)
      Loads a prefab from a file. This could be an fbx, obj or any other model file. If your model contains any textures you want to load automatically, it's recommended to put them into a zip file (together with the model file) and load the zip file.
      Parameter:
      file - the path to the model file.
      Gibt zurück:
      a new prefab asset instance.
    • loadFromFile

      public static PrefabAsset loadFromFile(String file, ModelImportSettings settings)
      Loads a prefab from a file. This could be an fbx, obj or any other model file. If your model contains any textures you want to load automatically, it's recommended to put them into a zip file (together with the model file) and load the zip file.
      Parameter:
      file - the path to the model file.
      settings - a settings object which enables you to influence how the model should be loaded.
      Gibt zurück:
      a new prefab asset instance.