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 robksawyer · May 08, 2015 at 05:42 PM · errorinputaudiomicrophone

MicInput Conversion to C#

I'm trying to convert the main Javascript MicInput script over to C# and I'm having some issues. I've been able to successfully convert the main MicInputJ file over with no more errors, but I'm having some issues with the VolumeBar class. I'm pretty new to Unity and C#, so this is likely most of my issue. Any help or clarification on what syntax is wrong would be greatly appreciated. See my current script and the errors below.


Errors

Assets/Editor/VolumeBarC.cs(22,76): error CS0119: Expression denotes a type', where a variable', value' or method group' was expected

Assets/Editor/VolumeBarC.cs(26,69): error CS1503: Argument #1' cannot convert object' expression to type float'`

Assets/Editor/VolumeBarC.cs(22,48): error CS1503: Argument #2' cannot convert object' expression to type UnityEngine.Texture'`

Assets/Editor/VolumeBarC.cs(22,48): error CS1502: The best overloaded method match for UnityEngine.GUILayout.Toggle(bool, UnityEngine.Texture, params UnityEngine.GUILayoutOption[])' has some invalid arguments`


VolumeBarC.cs

 using UnityEditor;
 using UnityEngine;
 using System.Collections;
 
 [CustomEditor(typeof(MicControlC))]
 public class VolumeBarC : Editor
 {
         
     MicControlC ListenToMic;
 
     /////////////////////////////////////////////////////////////////////////////////////////////////        
     void OnInspectorGUI ()
     {
         ListenToMic = (MicControlC)target;
 
         float micInputValue = MicControlC.loudness;
         ProgressBar (micInputValue, "Loudness");
 
         //show other variables
         
         //Redirect 3D toggle
         ListenToMic.ThreeD = GUILayout.Toggle (ListenToMic.ThreeD, GUIContent ("3D sound", "Should the streamed audio be a 3D sound? (Only enable this if you are using the controller to stream sound (VOIP) "));
 
         //when 3D audio is enabled show the fall off settings
         if (ListenToMic.ThreeD) {
             ListenToMic.VolumeFallOff = EditorGUILayout.FloatField (GUIContent ("Volume falloff", "Set the rate at wich audio volume gets lowered. A lower value will have a slower falloff and thus hearable from a greater distance, while a higher value will make the audio degrate faster and dissapear from a shorter distance"), ListenToMic.VolumeFallOff);
             ListenToMic.PanThreshold = EditorGUILayout.FloatField (GUIContent ("PanThreshold", "Set the rate at wich audio PanThreshold gets switched between left or right ear. A lower value will have a faster transition and thus a faster switch, while a higher value will make the transition slower and smoothly switch between the ears. Don't go to smooth though as this will turn your audio to mono channel"), ListenToMic.PanThreshold);
         }
         
         //Redirect select ingame
         ListenToMic.SelectIngame = GUILayout.Toggle (ListenToMic.SelectIngame, GUIContent ("Select in game", "select the audio source through a GUI ingame"));
         
         //Redirect Mute ingame
         ListenToMic.Mute = GUILayout.Toggle (ListenToMic.Mute, GUIContent ("Mute", "when dissabled you can listen to a playback of the microphone"));
         
         //Redirect debug ingame
         ListenToMic.debug = GUILayout.Toggle (ListenToMic.debug, GUIContent ("Debug", "This will write the gathered Loudness value to the console during playmode. This is handy if you want if statements to listen at a specific value."));
         
         //Redirect ShozDeviceName ingame
         ListenToMic.ShowDeviceName = GUILayout.Toggle (ListenToMic.ShowDeviceName, GUIContent ("Show Device name(s)", "When selected all detected devices will be written to the console during play mode"));
 
         EditorUtility.SetDirty (target);
         
         // Show default inspector property editor
         DrawDefaultInspector ();
     }
 
     // Custom GUILayout progress bar.
     void ProgressBar (float value, string label)
     {
         // Get a rect for the progress bar using the same margins as a textfield:
         Rect rect = GUILayoutUtility.GetRect (18, 18, "TextField");
         EditorGUI.ProgressBar (rect, value, label);
         EditorGUILayout.Space ();
     }
 }


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 robksawyer · May 08, 2015 at 05:35 PM 0
Share

I think I just solved it. I needed to have 'new' in front of my GUIContent calls. However, I'm sure there are some other optimizations that can be made. Any suggestions? Or is it good?

avatar image robksawyer · May 08, 2015 at 05:41 PM 0
Share

Hmm... I'm able to attach the $$anonymous$$icControl to a GameObject, but I don't get the fancy feedback sound bar or the drop downs. Is this a limitation of C# in Unity?

An example of my $$anonymous$$icControlC.cs script is located at: https://gist.github.com/robksawyer/d1aed220e77225928acd

avatar image robksawyer · May 08, 2015 at 06:06 PM 0
Share

Fixed my issues with $$anonymous$$icControlC.cs. I just needed to move my InputDevice declaration after the actual enum declaration and then add public to the audioListener and InputDevice. Updated the above linked script.

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Can't get multiple microphone channels 3 Answers

Help Audio streaming from microphone to online url. Uploading only 4kb chunk at a time. 1 Answer

What causes Microphone Start to not work, giving error result = 25? 0 Answers

Record Audio for triggering something 0 Answers

Real time Microphone (line input) FFT analysis 2 Answers


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