Shidongan

GuiScript

Nov 26th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.73 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. using System;
  5. using System.Diagnostics;
  6. using System.IO;
  7.  
  8. public class OnGuiScript : MonoBehaviour {
  9.  
  10.     public bool CanSaveGui = false;
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.     }
  15.  
  16.     public void SaveAudio(){
  17.         //helpGetPath = Path.Combine(nameProgramm, idCatcher);
  18.         SavWav.Save("myfile", GetComponent<RecordAu>().bofferAudioClip, Path.Combine(Application.persistentDataPath, Path.Combine(GetComponent<RecordAu>().nameProgramm, GetComponent<RecordAu>().idCatcher)));
  19.         GetComponent<RecordAu>().canSave = false;
  20.         //Debug.Log("Audio saved");
  21.     }
  22.  
  23.     void OnGui(){
  24.         if(GUI.Button(new Rect ( 10, 150 , 150, 50), "Test start")){
  25.             Process PrFoo = new Process();
  26.             PrFoo.StartInfo.FileName = "C:/Program Files (x86)/Far Manager/Far.exe";
  27.             PrFoo.Start();
  28.         }
  29.         if(!Microphone.IsRecording(GetComponent<RecordAu> ().deviceName)){
  30.             if(GUI.Button(new Rect ( 10, 10 , 150, 50), "Record")){
  31.                 RecordAu.registerAudio();
  32.  
  33.             }
  34.         }else{
  35.             if(GUI.Button(new Rect ( 10, 70 , 150, 50), "Stop Recording")){
  36.                 RecordAu.stopRecording();          
  37.             }
  38.         }
  39.        
  40.         if(GUI.Button(new Rect ( 10, 270, 150, 50), "Save")) {
  41.            
  42.             if(GetComponent<RecordAu>().hideLabel) {
  43.                 GUI.Label(new Rect(200, 270, 150, 50), "Audio Saved");
  44.                 GetComponent<RecordAu>().canSave = true;
  45.                 SaveAudio();
  46.                 GetComponent<RecordAu>().hideLabel=false;
  47.                 /*Debug.Log (GetComponent<runFilePath>().amountOfPrPaths + " - amount");
  48.                     Debug.Log (GetComponent<runFilePath>().ProgsPath[idPr].prPath + " - path");*/
  49.             }
  50.  
  51.         }
  52.        
  53.         if(Microphone.IsRecording(GetComponent<RecordAu> ().deviceName)){
  54.             GUI.Label(new Rect(200, 83, 150, 50), "Recording");
  55.         }else{
  56.             GUI.Label(new Rect(200, 23, 150, 50), "Not Recording");
  57.         }
  58.         GetComponent<RecordAu>().path = GUI.TextField(new Rect(400, 10, 150, 20), GetComponent<RecordAu>().path, 50);       // Ввод пути
  59.         GetComponent<RecordAu>().idCatcher = GUI.TextField (new Rect (400, 130, 150, 20), GetComponent<RecordAu>().idCatcher, 50);
  60.         GetComponent<RecordAu>().nameProgramm = GUI.TextField (new Rect (400, 270, 150, 20), GetComponent<RecordAu>().nameProgramm, 50); //Ввод названия       
  61.         Int32.TryParse(GetComponent<RecordAu>().idCatcher,out GetComponent<RecordAu>().idPr);                           //Из строки в число
  62.         //Debug.Log (idPr);
  63.  
  64.     }
  65.  
  66.     // Update is called once per frame
  67.     void Update () {
  68.         GetComponent<RecordAu>().canSave = CanSaveGui;
  69.     }
  70. }
  71.  
  72.  
  73.  
  74. Assets/Scripts/OnGuiScript.cs(31,42): error CS0120: An object reference is required to access non-static member `RecordAu.registerAudio()'
  75.  
  76. Assets/Scripts/OnGuiScript.cs(36,42): error CS0120: An object reference is required to access non-static member `RecordAu.stopRecording()'
Add Comment
Please, Sign In to add comment