Code Monkey home page Code Monkey logo

liteninja-cameraservices's Introduction

LiteNinja Camera Services

LiteNinja Camera Services is a collection of Camera-related services for Unity projects.

Camera Registry Service

A service that allows registering and retrieving cameras.

ICameraRegistry

ICameraRegistry is an interface that defines the contract for a camera registry service. It provides methods for registering, retrieving, and unregistering cameras.

Here are the key methods of the ICameraRegistry:

  • RegisterCamera(string id, Camera camera): This method allows you to register a camera with a unique string identifier. If a camera with the same identifier is already registered, it will be replaced.

  • GetCamera(string id): This method allows you to retrieve a camera using its unique string identifier. If no camera is registered with the given identifier, it returns null.

  • UnregisterCamera(string id): This method allows you to unregister a camera using its unique string identifier. If no camera is registered with the given identifier, the method does nothing.

  • CameraIds: This property returns an array of all registered camera identifiers.

  • OnCameraChanged: This event is invoked when a camera is registered or unregistered. The event handler receives the identifier of the changed camera.

CameraRegistry

CameraRegistry is a class that implements the ICameraRegistry interface. It uses a dictionary to store cameras, identified by a unique string ID.

Here's a basic usage example:

// Create a new CameraRegistry instance
ICameraRegistry cameraRegistry = new CameraRegistry();

// Register a camera
Camera mainCamera = Camera.main;
cameraRegistry.RegisterCamera("Main", mainCamera);

// Retrieve a camera
Camera retrievedCamera = cameraRegistry.GetCamera("Main");

// Unregister a camera
cameraRegistry.UnregisterCamera("Main");

Remember to add a listener to the OnCameraChanged event if you want to be notified when a camera is registered or unregistered:

cameraRegistry.OnCameraChanged.AddListener((string id) => {
    Debug.Log($"Camera changed: {id}");
});

liteninja-cameraservices's People

Contributors

sponticelli avatar

Watchers

 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.