Git Product home page Git Product logo

unity-world-ex's Introduction

unity-world-ex

Extension for Unity to support worlds instead of scenes. Worlds are multiple scenes.

install

Use this repository directly in Unity.

Dependencies

Open UPM

URL: https://package.openupm.com

Scopes:

  • org.pcsoft
  • com.marijnzwemmer

usage

Setup your world system in project settings: editor

To load worlds use always WorldSystem class.

This project adds support for worlds. A double click on a world asset opens all contained scenes.

‼️ Do not combine this with Unity Scene Extensions

Parameter System

To use parameters you can create own parameter classes they must extends from ParameterData. Additional, to setup initila data for this parameters via Unity Editor you can create a simple ScriptableObject for this specific parameter data:

public interface IMyParameter 
{
  string Text { get; }
}

public sealed class MyParameterInitialData : ScriptableObject, IMyParameter
{
  [SerializeField]
  private string text;
  
  public string Text => text;
}

[ParameterInitialDataType(typeof(MyParameterInitialData))]
public sealed class MyParameterData : ParameterData, IMyParameter 
{
  private const string MyKey = "my.key";

  public string Text
  {
    get => Get<string>(MyKey);
    set => Add(MyKey, value);
  }
  
  public override void InitializeData(ScriptableObject initData) 
  {
    Text = ((MyParameterInitialData)initData).Text;
  }
}

To access the parameter simply use WorldParameter:

var parameter = WorldParameter.GetData<MyParameterData>();

If the parameter does not exists it is created and initialized by system and calling method InitializeData with scriptable object data setup in project settings.

Events & Additional Scenes / Actions

To handle own actions you can add static callbacks for blending state changes and scene state changes:

[RuntimeOnSwitchScene(RuntimeOnSwitchSceneType.LoadScenes)]
public static void SwitchSceneLoad(RuntimeOnSwitchSceneArgs args)
{
    //...

    if (args.Identifier == MenuKey)
    {
        args.AdditionalScenes = new[] { SceneParameter.GetData<MenuParameter>().MenuScene };
    }
    
    //...
    
    args.Callback.Invoke();
}

So you can add additional scenes to load or unload.

[RuntimeOnBlendScene(RuntimeOnBlendSceneType.PostShowBlend)]
public static void SwitchBlend(RuntimeOnBlendSceneArgs args)
{
  //...
  
  args.Callback.Invoke();
}

So you can do actions on specific blend actions.

Please note: It is required to invoke callback method to continue!

unity-world-ex's People

Contributors

kleinerhacker avatar

Stargazers

MetalSlugX3 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.