playMaker

Author Topic: PlayMakerHashTableProxy get key error [SOLVED]  (Read 1649 times)

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
PlayMakerHashTableProxy get key error [SOLVED]
« on: June 07, 2017, 08:52:32 AM »
Hi

I am using the ArrayMaker and HashTables script and i am using the following code and i get an error message.
Code: [Select]
Debug.Log (GetComponent<PlayMakerHashTableProxy>().hashTable["test"]);
error
Quote
NullReferenceException: Object reference not set to an instance of an object
CharacterSelectionScreenNGUI.OnEnable () (at Assets/Scripts/MLM/CharacterSelectionScreenNGUI.cs:10)
UnityEditor.DockArea:OnGUI()

if i check the hashtable prefill count i get a value, so just seems i cant reference a key or value from a hashTable.
Code: [Select]
Debug.Log (GetComponent<PlayMakerHashTableProxy>().hashTable.preFillCount);
Why do i get this message?

full code
Code: [Select]
using UnityEngine;
using HutongGames.PlayMaker;

[ExecuteInEditMode]
public class CharacterSelectionScreenNGUI : MonoBehaviour
{

void OnEnable () {

Debug.Log (GetComponent<PlayMakerHashTableProxy>().hashTable["test"]);
}

}

« Last Edit: June 13, 2017, 08:37:58 AM by coxy17 »

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: PlayMakerHashTableProxy get key error
« Reply #1 on: June 13, 2017, 03:29:12 AM »
bump

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayMakerHashTableProxy get key error
« Reply #2 on: June 13, 2017, 05:56:37 AM »
Hi,

thanks for the bump, I need this :)

It's because The proxy data is handled differently at runtime then editor time.

 so hashtable is empty if you try to access it at editor time,

use preFillKeyList and preFillXXXList during editing time to get the value you have inputed manually

you can pick the right prefill list by checking .preFillType

Check the method PreFillHashTable inside the proxy class to see how data is handled during editing and run time.

Let me know if you still struggle with this.

Bye,

 Jean

coxy17

  • Beta Group
  • Sr. Member
  • *
  • Posts: 355
Re: PlayMakerHashTableProxy get key error [SOLVED]
« Reply #3 on: June 13, 2017, 08:37:46 AM »
no worries Jean

Yes i got it working now. Thanks man!

Nick

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: PlayMakerHashTableProxy get key error [SOLVED]
« Reply #4 on: June 14, 2017, 04:59:06 AM »
excellent :) I am glad you could make progress on this.

 Bye,

 Jean