Skip to content
Useful pieces of code for Unity projects.
C#
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Runtime
Test
.gitignore
LICENSE
LICENSE.meta
README.md
README.md.meta
Runtime.meta
Test.meta
package.json
package.json.meta

README.md

Cicanci Utils

Useful pieces of code for Unity projects. Check out the sample project here.

Installation

Open the Package Managed in the Unity Editor (Window/Package Manager). Then, click in the plus button to add a new package by selecting the Add package from git URL... option.

1-add-package

Type in this repository URL, you can use SSH git@github.com:cicanci/cicanci-utils.git or HTTPS https://github.com/cicanci/cicanci-utils.git.

2-add-from-github

Finally, the package will be imported and the Package Manager window will show you the version and other details. If you want to uninstall the package, just click in the Remove button in this screen after selecting the package in the left menu.

3-imported-package

Usage

Here you will find the list of functionalities in this package, new features will be added periodically. Remeber to always include the folowing line at the beginning of your script so the package funcionalities will be available for you:

using Cicanci.Utils;

Message Manager

The following script shows how to add a listener in the Start method, remove it in the OnDestroy method, and send a message with a greeting. The class MyMessage represents the object sent and received.

In the script below you will need to call the method SendMessage in order to fire the message.

using Cicanci.Utils;
using UnityEngine;

public class MessageBehaviour : MonoBehaviour
{
    private void Start()
    {
        MessageManager.Instance.AddListener<MyMessage>(OnMessageReceived);
    }

    private void OnDestroy()
    {
        MessageManager.Instance.RemoveListener<MyMessage>(OnMessageReceived);
    }

    private void OnMessageReceived(MyMessage message)
    {
        Debug.Log(message.Greetings);
    }

    public void SendMessage()
    {
        MyMessage message = new MyMessage { Greetings = "Hello, World!" };
        MessageManager.Instance.SendMessage(message);
    }
}

public class MyMessage
{
    public string Greetings;
}
You can’t perform that action at this time.