Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by AlucardJay · Oct 24, 2013 at 06:38 AM · photonhashtablecollections

Overload methods of Hashtable using System and Photon namespaces

Project is in uJS and using Photon PUN.

So I'm trying to use a hashtable for setting some custom properties in the Photon player custom properties :

 function ResetScores() 
 {
     var props : Hashtable = new Hashtable();
     
     props.Add( "Kills", 0 );
     props.Add( "Deaths", 0 );
     props.Add( "Assists", 0 );
     
     PhotonNetwork.player.SetCustomProperties( props );
 }

Now the only reference to uJS hashtables is here but there is no example of adding keys and values. I check a MSDN example and a few Photon questions and they are all in C#, but declared the same.

well that gave the error :

 Assets/_Scripts/GameManager.js(386,57): BCE0017: The best overload for the method 'PhotonPlayer.SetCustomProperties(ExitGames.Client.Photon.Hashtable)' is not compatible with the argument list '(System.Collections.Hashtable)'.

I'm using generic List in the same script :

 import System.Collections.Generic;
 public class GameManager extends Photon.MonoBehaviour {

so thinking I had to use the photons system of collection, I tried using :

 var props : ExitGames.Client.Photon.Hashtable = new Hashtable();

which gave the error :

 Assets/_Scripts/GameManager.js(380,69): BCE0022: Cannot convert 'System.Collections.Hashtable' to 'ExitGames.Client.Photon.Hashtable'.

This is the first time I've used hashtable, all out of ideas and could really do with some advice and/or help. Maybe the problem is using System.Collections or Photon.MonoBehaviour ?

Thanks for reading.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Oct 28, 2013 at 04:56 PM 0
Share

Please help.

Should I be importing namespaces? If not, I need a re$$anonymous$$der on how to use a namespace on a variable only. How can I use Systems namespace for List, and Photon namespace for Hashtable?

Edit :

 var spawnPoints : System.Collections.Generic.List.< SpawnPoint >;

gives the error

 Assets/_Scripts/Game$$anonymous$$anager.js(65,28): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?

using :

 var props : Photon.Hashtable = new Hashtable();

gives the error :

 Assets/_Scripts/Game$$anonymous$$anager.js(428,29): BCE0018: The name 'Photon.Hashtable' does not denote a valid type ('not found'). Did you mean 'ExitGames.Client.Photon.Hashtable'?

using :

 var props : ExitGames.Client.Photon.Hashtable = new Hashtable();

gets me closer, but now I'm back to the original error :

 Assets/_Scripts/Game$$anonymous$$anager.js(428,69): BCE0022: Cannot convert 'System.Collections.Hashtable' to 'ExitGames.Client.Photon.Hashtable'.

Edit 2 :

I've now posted this question on the forums. $$anonymous$$y guess is everyone here hates me. Unless one of the top two users here on UA responds, I never get any help ....

avatar image plokkum · Feb 24, 2015 at 05:37 PM 0
Share

Also, to optimise it a little bit, try to keep the hash keys as small as possible. For instance, ins$$anonymous$$d of "$$anonymous$$ills", call it "$$anonymous$$L".

avatar image HungTr · Jun 15, 2017 at 07:48 AM 0
Share
 You have to define that you want to use Photon's Hashtable class. This is done by adding a "using" statement at the top of your class. Like so:
 
 using UnityEngine;
 using System.Collections;
 using Hashtable = ExitGames.Client.Photon.Hashtable;

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Jamora · Oct 28, 2013 at 06:57 PM

Have you tried

 var props : ExitGames.Client.Photon.Hashtable = new ExitGames.Client.Photon.Hashtable();

Looked like you were trying to fit a System Hashtable to the Photon Hashtable...

you could also try importing the photon namespace instead of the System one.

 import ExitGames.Client.Photon;

So now

 var props : Hashtable = new Hashtable();

should mean the Photon one, and not the System one.

Even though you're not using C#, I assume there's something similar to aliases in UnityScript. In C#, I would declare an alias by

 using PhotonHashTable = ExitGames.Client.Photon.Hashtable;

right below all the other using directives. Now the compiler knows, at compile-time, to swap each instance of PhotonHashTable into that dot-monster.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image AlucardJay · Oct 29, 2013 at 09:56 AM 0
Share

Thank you Jamora. Now I see it, it seems so obvious :S Really appreciate the help.

Using :

 import ExitGames.Client.Photon;

Gives an Ambiguous reference error but I can understand why.

 Assets/_Scripts/Damageable.js(238,56): BCE0004: Ambiguous reference 'Hashtable': ExitGames.Client.Photon.Hashtable, System.Collections.Hashtable.

So for now, declaring the class to use locally is fine. Again, many thanks for your help.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

17 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Strange nullReferenceError when dealing with Hashtables and Photon 2 Answers

C# Multidimensional Collection to Store and Retrieve Character Information 1 Answer

[PUN] Server List GUI Help 1 Answer

photon free for unity free to android 0 Answers

PhotonNetworkConnectManually Error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges