Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Overload methods of Hashtable using System and Photon namespaces

Discussion in 'Scripting' started by AlucardJay, Oct 28, 2013.

  1. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
    Firstly, this question is also posted on UA, but after 4 days 12 views and no response I am seeking help here. IF I get an answer/response anywhere, I shall forward the information to the duplicate post (sorry for double-posting, but UA is not helping) : http://answers.unity3d.com/questions/562204/overload-methods-of-hashtable.html

    I am having issues with importing and using different class 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 :

    Code (csharp):
    1.  
    2. function ResetScores()
    3. {
    4.          var props : Hashtable = new Hashtable();
    5.        
    6.         props.Add( "Kills", 0 );
    7.         props.Add( "Deaths", 0 );
    8.         props.Add( "Assists", 0 );
    9.        
    10.         PhotonNetwork.player.SetCustomProperties( props );
    11. }
    12.  
    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 :

    Code (csharp):
    1.  
    2. 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)'.
    3.  
    I'm using generic List in the same script :

    Code (csharp):
    1.  
    2. import System.Collections.Generic;
    3. public class GameManager extends Photon.MonoBehaviour {
    4.  
    so thinking I had to use the photons system of collection, I tried using :

    Code (csharp):
    1.  
    2. var props : ExitGames.Client.Photon.Hashtable = new Hashtable();
    3.  
    which gave the error :

    Code (csharp):
    1.  
    2. Assets/_Scripts/GameManager.js(380,69): BCE0022: Cannot convert 'System.Collections.Hashtable' to 'ExitGames.Client.Photon.Hashtable'.
    3.  
    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.

    Edit :

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

    Using :

    Code (csharp):
    1.  
    2. var spawnPoints : System.Collections.Generic.List.< SpawnPoint >;
    3.  
    gives the error

    Code (csharp):
    1.  
    2. Assets/_Scripts/GameManager.js(65,28): BCE0018: The name 'List' does not denote a valid type ('not found'). Did you mean 'UnityEngine.Light'?
    3.  
    using :

    Code (csharp):
    1.  
    2. var props : Photon.Hashtable = new Hashtable();
    3.  
    gives the error :

    Code (csharp):
    1.  
    2. Assets/_Scripts/GameManager.js(428,29): BCE0018: The name 'Photon.Hashtable' does not denote a valid type ('not found'). Did you mean 'ExitGames.Client.Photon.Hashtable'?
    3.  
    using :

    Code (csharp):
    1.  
    2.  var props : ExitGames.Client.Photon.Hashtable = new Hashtable();
    3.  
    gets me closer, but now I'm back to the original error :

    Code (csharp):
    1.  
    2. Assets/_Scripts/GameManager.js(428,69): BCE0022: Cannot convert 'System.Collections.Hashtable' to 'ExitGames.Client.Photon.Hashtable'.
    3.  
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    2,919
    Did you try

    Code (csharp):
    1.  
    2. var props : ExitGames.Client.Photon.Hashtable = new ExitGames.Client.Photon.Hashtable();
    3.  
    ?
     
  3. AlucardJay

    AlucardJay

    Joined:
    May 28, 2012
    Posts:
    328
    Thank you Tomas1856. Now I see it, it seems so obvious :S Really appreciate the help.
     
unityunity