whydoidoit / of-type

Provides a PlayCanvas method to find all children that have a particular script or component and return that component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

Adds a method to pc.Entity to return an array of components or scripts that match the search term suppllied

Installation

npm install --save playcanvas-of-type

Usage

import 'playcanvas-of-type'

...

//Get collision components
this.entity.ofType('collision').forEach(doSomething);

this.entity.ofType('myscript').forEach(script=>{
    script.method();
}); 
 

Requirements

Requires PlayCanvas Engine to be running on the page. Uses ES6/Babel/PlayCanvas template.

About

Provides a PlayCanvas method to find all children that have a particular script or component and return that component


Languages

Language:JavaScript 100.0%