npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

io.magicave.solid-unity

v0.10.11

Published

Magicave Solid Unity SDK allows developers to integrate Magicave assets into their project.

Downloads

357

Readme

dNo Unity SDK

About

Unity package for accessing owned dNo Dice for users in your Unity project. The SDK interfaces with the dNo Cloud API.

The SDK has been tested to work with the following platforms;

  • PC Standalone (Windows & Mac)
  • Android
  • iOS
  • WebGL

Discord

As a game dev working in the dNo community join the dNo Discord. There you can discuss ideas and get support with your integration.

Requirements

These are some dependencies of the package;

  • Unity Addressables - this Unity asset management package has been used load 3d assets of our digital toys.
  • URP (Universal Render Pipeline) - the 3d assets have been built with this pipeline and it's required to render the assets in game.
  • Firebase Authentication - Firebase/Google authentication used to sign in players before we can retrieve owned assets.

Getting started

As stated in the in the Requirements section make sure that the Unity project has been create to work with URP.

The dNo Unity SDK is an UPM (Unity Package Manager) package that is hosted in npmjs.org and as such the Unity Package Manifest needs to be updated with the following;

{
  "dependencies": {
    ...
    "io.magicave.solid-unity": "0.9.2"
  },
  "scopedRegistries": [
    {
      "name": "npmjs",
      "url": "https://registry.npmjs.org/",
      "scopes": [
        "io.magicave"
      ]
    }
  ]
}

Now you are good to open up the Unity project. As mentioned in the Requirements section the SDK uses Unity Addressables. If your project doesn't use Addressables you need to run a default Addressables build to set up the appropriate config.

You are now ready to start interfacing with dNo 🚀.

Samples

In the Package Manager window you'll see that there are two Samples that can be imported for Magicave Solid SDK; WebGL Template and Basic Game Workflow. The latter will demonstrate how to interact with the SDK.

Click Import then there will be four scenes inside Assets/Samples/BasicGameWorkflow/Assets/Scenes that show how to initialise the SDK, sign in a User, inspect owned Dice and eventually see the 3d Dice assets.

The extract below is based on the GameInitialization.cs script found in the Samples but demonstrates how quickly

using System;
using Magicave.Solid.Runtime;
using Magicave.Solid.Runtime.Models;
using UnityEngine;

public class GameInitialization : MonoBehaviour
{
    private async void Start()
    {
        try
        {
            await SolidSdk.Init();
        
            // now ready to start interacting with the SDK

            var magicaveUser = SolidSdk.Auth.User;
            if (magicaveUser.HasAuth(UserAuthState.WalletConnected))
            {
                print($"User {magicaveUser.Uid} has their wallet connect: {magicaveUser.WalletAddress}");
            }

            foreach (IDiceSet ownedDiceSet in SolidSdk.Assets.OwnedDiceSets)
            {
                print($"Owned dice {ownedDiceSet.Uid}");
            }
        }
        catch (Exception e)
        {
            Debug.LogException(e);
            Debug.LogError("Unable to start the Magicave SDK");
        }
        
    }
}

Loading Assets

The 3d Dice assets can be loaded directly from the IDiceSet objects that were being inspected above.

foreach (var assetPair in await ownedDiceSet.GetAssets())
    {
        var go = Instantiate(assetPair.Value as GameObject);
    }

Where each DiceSet has the following dice types; D4, D6, D8, D10, D12, D20, D100

Authentication

For a player to use the Dice sets they own you need to be able to sign them into their account. A Magicave account can be created, or signed into, with email and password. (NB: the connection of a Web3.0 wallet is done on our dNo Web app outside of the Unity SDK).

private async UniTask _SignIn(SignInRequestType requestType)
    {
        try
        {
            var email = emailInputField.text;
            var password = passwordInputField.text;
            
            await SolidSdk.Auth.SignIn(new SignInRequest(email, password, requestType));
            
            signInScreen.SetActive(false);
            
            Refresh();
        }
        catch (Exception e)
        {
            ShowErrorMessage(e.Message).Forget();
        }
    }