Coder Social home page Coder Social logo

animaskin's Introduction

AnimaSkin

If you have been having issues with skin management in Anima2D, you have found the right asset. As of today, I have not found a good solution to creating and loading skins for Anima characters on the fly, therefore, I decided to create one myself.

How do I use it?

Anima Skin has 2 simple scripts to use:

  • SkinManager: Attach this script to the root GameObject of your character.

alt text

  • Skin: Attach this script to an empty GameObject as a child of your character.

alt text

The Skin Manager

The skin manager can be added to the root GameObject of the character. The manager has three visible variables:

  • Current Skin: A copy of the currently set Skin.
  • Skin Holder: Drag the GameObject that contains the "Skin" scripts. If you don't have / want one, leave it empty and the manager will try to find them.
  • Skins: Is a list that will show the Skins identified by the manager in the object that you dragged above.

The Variables

The following variables are public in the Skin Manager script instance:

  • skins: The list of the current Skins.
  • currentSkin: A copy of the currently set Skin.
  • defSkin: The default Skin the character had when the scene started.
  • skinHolder: The GameObject that contains the skins ( this is the field in the Editor we saw earlier ).

The Functions

The Skin Manager has the following public functions (At the moment):

  • RefreshSkins() : Refreshes the skins in the GameObject.
  • RestoreBaseSkin(): Restores the character to the skin that it had when the scene started.
  • LoadSkinByString(string skinName): Loads the skin with the name passed as a parameter. It will let you know if it couldn't find it. For better debugging, check the Skins list in the manager at runtime!
  • LoadSkin(Skin skinToSet): Loads the skin passed as a parameter. You can use this to create Skins at runetime and set them to the character. Wow!
  • SearchSkin(string skinName): Searches the skin, with the name passed as a parameter, and returns the index of it in the skins list in the Skin Manager, it will return " -1 " if it can't find it.

The Skin Component

The skin component will be used to create the skins for the character. It has the following visible fields in the Editor:

  • Skin Name: The name of the skin as a string, it will be used to load them with the Skin Manager. Do NOT REPEAT NAMES, or it won't work.
  • Skin Parts: A list with references to the Sprite Mesh Instances of the character (or other object). The SpriteMesh field will determine what Sprite Mesh is loaded to the body part determined by the instance on the left. Pretty easy right?

Adding References to a Skin

You can add multiple Sprite Mesh Instance references to the Skin Manager by selecting the parent object that contains the Skins in the editor, then press the "+" button in the list and click on "From Selection". This will add references to all the Sprite Mesh Instances found as children of the object selected. What a great feature!

animaskin's People

Contributors

sergioaa97 avatar

Watchers

 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.