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 /
This question was closed Oct 25, 2014 at 05:04 PM by Blayer98 for the following reason:

I'm not bothering with this anymore.

avatar image
0
Question by Blayer98 · Oct 25, 2014 at 02:08 PM · exceptionboolifvoid

How to make a file run if a void has undefined coordinates?

Hello! (Sorry about the title, I didn't know what to call it...)

I'm trying to get a vbs script to load (debugging purposes.) but since StartClip is a void, not a bool, the 'if' statement won't work. Is there another alternative?

the error code: 'error CS0029: Cannot implicitly convert type void' to bool''

I'm making an exception handler, by the way. So if the PlayLengthLoop (The script's name.) has (0.0f, 0.0f) as a start and end loop, the game should open the test.vbs file. (Eventually, I'll make it so that it would load another level to prevent the Unity Editor and the built game from crashing.)

using UnityEngine; using System.Collections; using System.Diagnostics;

 public class PlayLengthLoop : MonoBehaviour {
 
     public AudioClip audioClip;
 
     void Start()
     {
        //
         StartClip(0.0f,0.0f);
 
     }
 
     void StartClip(float timeStart, float timeEnd)
     {
        audio.clip = audioClip;
        audio.time = timeStart;
        audio.Play();
        StartCoroutine(DelaySoundStop(timeEnd));
     }
 
     IEnumerator DelaySoundStop(float timeEnd)
     {
        while(audio.time < timeEnd)
          yield return null;
        StartClip(0.0f,0.0f);
        //Add your own times here !
         if (StartClip(0.0f,0.0f));
         System.Diagnostics.Process.Start(@"C:\Users\-----\Desktop\test.vbs");
        

     }
 }
Comment
Add comment
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

1 Reply

  • Sort: 
avatar image
1

Answer by gjf · Oct 25, 2014 at 02:36 PM

what you're doing is, err, unconventional but you'd need to change StartClip() to something like this:

 private bool StartClip(float timeStart, float timeEnd)
 {
     audio.clip = audioClip;
     audio.time = timeStart;
     audio.Play();
     StartCoroutine(DelaySoundStop(timeEnd));
 
     return ((timeStart == 0.0f) && (timeEnd == 0.0f))
 }

and lose the semicolon on line 26.

ALTHOUGH why on earth you're calling it from the coroutine that it starts is rather mysterious... on re-reading your question, if you're trying to make an exception handler this is not how you'd do it... to look try/catch/throw/finally/etc.

Comment
Add comment · Show 2 · 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 Blayer98 · Oct 25, 2014 at 02:38 PM 0
Share

how is it unconventional? :/

avatar image gjf · Oct 25, 2014 at 02:40 PM 0
Share

calling vbs from unity...see my amended comment. if you want some sort of debug logging, can't you just log to a file?

and with reference to your question title, 'void' is a return type for a function/method.

Follow this Question

Answers Answers and Comments

27 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why does Unity mean with :Cannot implicitly convert type `void' to `bool' ? 3 Answers

if Application.LoadLevel Error 1 Answer

How actions in if() are carried out depending on booleans? 1 Answer

How to make an if command check a bool (or any other variable) only if it has changed 1 Answer

activating multiple voids with the same name trough one line 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