Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - faceOFF

Pages: [1]
1
NGUI 3 Support / Need UISavedPopup.cs something as for UISavedOption.cs
« on: August 23, 2012, 12:00:48 AM »
It seems like "UISavedOption.cs" only can be read and save string from Options (in the inspector "UIPopupList")
For example I have three modes of game speed,  when I need to change speed value It's stored and then read.

2
NGUI 3 Support / Slider Value not change from PlayerPrefs...
« on: August 22, 2012, 06:32:53 AM »
Why AudioListener.volume - it remember fine, but Slider Value not  ???  ?

  1. using UnityEngine;
  2. using System.Collections;
  3. using System.IO;
  4.  
  5.  
  6. public class onSliderChange : MonoBehaviour
  7. {
  8.         public GameObject slider;
  9.        
  10.         void Start (float volume)
  11.         {
  12.                 AudioListener.volume = PlayerPrefs.GetFloat("Sound");
  13.                 volume = PlayerPrefs.GetFloat("Sound");
  14.         }
  15.        
  16.        
  17.     void OnSliderChange (float volume)
  18.     {
  19.                 // AudioListener.volume = volume;
  20.                 AudioListener.volume = PlayerPrefs.GetFloat("Sound");
  21.                 PlayerPrefs.SetFloat("Sound", volume);
  22.                 PlayerPrefs.Save();
  23.     }
  24. }

3
There is a JS script output of my SQL databases to GUI.Label and it works great!
But as you know, this method does not support dynamic fonts, and correspondingly different screens on the Android devices ..
I'm trying to display text in UILabel.tex from JS:
  1. public var scriptEnabled:boolean = false;  //Set to true when you want the score submitted.
  2. //public var windowRect : Rect = Rect (20, 20, 20, 20);
  3. //public var useSizeAsPadding:boolean = true;
  4. public var phpScriptFolder:String = "http://example.com/leaderboard/";
  5.  
  6. public var cellWidth:int = 100;
  7. public var sortBy:String = "var0";
  8. public var start:int = 0;
  9. public var count:int = 100;
  10. public var condition:String[]; //This is for selecting levels, usernames, etc. IE, using my default 4 variables,
  11.                                                                                 // to check for a level named demo you would type in var3 = "Demo"
  12. public var exclusionList:String[] = ["id"];
  13. public var direction:String = "DESC"; //DESC for descending ASC for ascending
  14. public var refresh:boolean = false;
  15. //public var guiID:int = 1;
  16. public var labelScore:GameObject;
  17.  
  18. private var i:int = 0;
  19.  
  20. var scores:Array = new Array("");
  21. private var gettingScores:boolean = false;
  22.  
  23. function Start()
  24. {
  25.         for(i = 0; i<= count; i++)
  26.         {
  27.                 scores.Push("");
  28.         }
  29.         i=0;
  30. }
  31.  
  32. function Update()
  33. {
  34.         if(refresh)
  35.         {
  36.                 GetScores();
  37.                 refresh = false;
  38.         }
  39. }
  40.  
  41. function GetScores()
  42. {
  43.         gettingScores = true;
  44.         var tmpExclude:String;
  45.         for(var field in exclusionList)
  46.         {
  47.                 if(field != "")
  48.                 {
  49.                         tmpExclude += field + "~";
  50.                 }
  51.         }
  52.         var conditions:String = "&conditions=";
  53.         for(i = 0; i < condition.Length; i++)
  54.         {
  55.                 conditions += condition[i].Replace("=", "----").Replace(" ", "%20") + "~"; //Replace fixes not having the extra = in a url, which breaks the url.
  56.         }
  57.         var res:WWW = new WWW(phpScriptFolder + "/getScores.php?sort=" + sortBy + "&direction="+ direction + "&start=" + start + "&limit=" + count + "&exclude=" + tmpExclude + conditions);
  58.         print(phpScriptFolder + "/getScores.php?sort=" + sortBy + "&direction="+ direction + "&start=" + start + "&limit=" + count + "&exclude=" + tmpExclude + conditions);
  59.         yield res;
  60.         print(res.text);
  61.         var resTmp = res.text;
  62.         var tmp:Array = resTmp.Split("\\"[0]);
  63.         scores = tmp;
  64.         gettingScores = false;
  65.         //NGUIScorePrint ();
  66. }
  67.  
  68. function OnGUI ()
  69. //function NGUIScorePrint ()
  70. {
  71.         if(scriptEnabled)
  72.         {
  73.                 if(scores[0] == "")
  74.                 {
  75.                        
  76.                         if(gettingScores == false)
  77.                         {
  78.                                 GetScores();
  79.                         }
  80.                        
  81.                 }
  82.                 else
  83.                 {
  84.                         Leaderboard();
  85.                 }
  86.                 if(scores[0] != "")
  87.                 {
  88.                         //Resets scores so that it looks for new information when displayed again.
  89.                         scores = new Array();
  90.                         for(i =0; i<= count; i++)
  91.                         {
  92.                                 scores.Push("");
  93.                         }
  94.                 }
  95.         }      
  96. }
  97.  
  98. function Leaderboard ()
  99. {
  100.         for(i = 0; i <= scores.Count-1; i++)
  101.         {
  102.                 var tmp:Array = scores[i].ToString().Split("\\"[0]);
  103.                 var j:int = 0;
  104.                 for(j = 0; j <= tmp.Count-1; j++)
  105.                 {
  106.                         //labelScore.GetComponent(UILabel).text = tmp[j].ToString();
  107.                         labelScore.GetComponent(UILabel).text = scores.ToString();
  108.                 }
  109.         }
  110. }

But getting the output:
hendry;87400,aLDime=);74400,taz;37900,F;37700,nat1;36400,miki ser;34400,hendry;29900,toad;29300,shaggy;21600,florent;20900,nat1;17300,msr;17000,hendry;12800,CM;10100,tttttt;9400,f2241;9100,ziol;8400,taz;7900,哦;3300,

No spaces and newline!
As I see, C# does not understand this line:
  1. var tmp:Array = scores[i].ToString().Split(";"[0]);

I know it's a matter of language JS and C #, and the answer is somewhere nearby, but I'm at an impasse and beg for help! If you can not make the "Array" from JS to C #, may be then tell how to do that would UILabel . text did sign with the appearance of a space ";" and the transfer line with ","
Excuse me, I'm newbie))
Before very grateful!!!

4
I have a script in Java:
  1. var input : GameObject;
  2.  
  3. function Awake ()
  4. {
  5.         input.GetComponent(onSubmitJS).string = ToString(UILabel.text);
  6. }

In summary: Assets/Scripts/onSubmitLabelNameJS.js(5,66): BCE0020: An instance of type 'UILabel' is required to access non static member 'text'.

In general, I need GetComponent from Input / UILabel in my script "SubmitLeaderBoard.js"
Maybe can I do it in C#?
Then how do GetComponent from C# to JS?

Rephrase the question: How do I send OnSubmit "Player Name" from the Input / UILabel
in my script "SubmitLeaderBoard.js" in the string variable "username"?
  1. public var username:String = "";

5
NGUI 3 Support / Waiting before ("OnPress") exit
« on: July 11, 2012, 03:21:54 AM »
Hello everybody!

I make button "Exit", and I need pause 1-2 sec for play sound "goodbye" and to see press button (change color)on Android screen,
But IEnumerator ExitGame () does not work:
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Exit : MonoBehaviour
  5. {      
  6.  
  7.         public AudioClip SoundGoodBy;
  8.        
  9.        
  10.         void OnPress(bool isPressed)
  11.                
  12.         {      
  13.                 Debug.Log("Press Exit");
  14.                 AudioSource.PlayClipAtPoint(SoundGoodBy,transform.position );
  15.                 ExitGame ();           
  16.         }
  17.        
  18.        
  19.         IEnumerator ExitGame()
  20.                
  21.         {
  22.                 Debug.Log("Wait 2 sec");
  23.                 yield return new WaitForSeconds (2);
  24.                 Application.Quit();
  25.                 Debug.Log("Exit Game !!!");
  26.         }
  27.        
  28. }
What I do wrong?
Thanks!

6
NGUI 3 Support / Score to string in NGUI.
« on: July 10, 2012, 01:57:08 AM »
Greetings to all!

I use JS:
  1. function Update()
  2. {
  3.         //draw the score in NGUI
  4.         GameObject.Find("LabelScore").GetComponent(UILabel).text += scorePoints;
  5. }
  6.  

Thus UILabel out display not the Score but infinite line of figures.
Example, if the Score is equal to zero, it deduces:
000000000000000000000000000000000000000000000000000 (infinitely).
How to solve? There is a something like .ToString () for (UILabel).text?

Excuse for my english ;)

Pages: [1]