playMaker

Author Topic: find prefab by name?[SOLVED]  (Read 2545 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
find prefab by name?[SOLVED]
« on: July 27, 2016, 02:58:46 PM »
is this possible? any time i want an fsm to use a prefab, it seems i need to manually grab it in the assets folder and drag it into the desired field. can I just have the fsm search the  assets folder for a prefab and use it on the spot?

example: a grid that contains mini models of furniture. when you click on one, it checks the name of the model you clicked on, finds a prefab with the same name, and creates it and puts it into your hand.

« Last Edit: August 10, 2016, 03:19:47 AM by jeanfabre »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: find prefab by name?
« Reply #1 on: July 28, 2016, 07:18:00 AM »
Hi,
What you can do is place your prefabs into a hashtable.

To do this you need to get the "array maker" package on the Ecosystem
(Ecosystem seach has a little problem atm, just spam search untill you get a result)

you can find some array maker tutorials here

Hashtable works almost the same as arraylists except it uses keys instead of index numbers.

So you can place you prefabs and name the keys with the name you want to use for that prefab.

When you can't figure it out let me know :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: find prefab by name?
« Reply #2 on: July 28, 2016, 08:57:45 AM »
Hi,

You should also study "resources" which gives you a better memory management if only some of this prefabs may be used.

Bye,

Jean

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Re: find prefab by name?
« Reply #3 on: July 29, 2016, 02:10:39 AM »
thanks guys I will look into it!