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
2
Question by AVividLight · Dec 18, 2012 at 10:07 PM · c#startupparametersenvironmentarguments

Parameters at Startup

Hey guys,

I'm having a great deal of trouble figuring out how to get parameters on an application's StartUp. I've been working on this almost all day, but nothing seems to work. I can't give Start() parameters, and I can't get Environment.GetCommandLineArgs to return any value. Maybe I'm sending the parameters wrong, but I'm getting tired of trying to figure this out. If any of you can give me a quick example, I'll be really grateful!

Thanks for your time - Gibson

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

· Add your reply
  • Sort: 
avatar image
10
Best Answer

Answer by Dom3D · Dec 19, 2012 at 02:12 AM

Under OSX I made the following testrun, maybe it helps you to find your issue

Terminal line:

 open CMDTest.app/ --args -myarg andstuff and more

MonoBehavior

 using UnityEngine;
 using System.Collections;
 using System;
 
 public class Info : MonoBehaviour 
 {    
     static string cmdInfo = "";
 
     void Start () 
     {
         string[] arguments = Environment.GetCommandLineArgs();
         foreach(string arg in arguments)
         {
             cmdInfo += arg.ToString() + "\n ";
         }
     }
     
     void OnGUI()
     {
         Rect r = new Rect(5,5, 800, 500);
         GUI.Label(r, cmdInfo);
     }
 }
 
Comment
Add comment · Show 7 · 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 AVividLight · Dec 19, 2012 at 08:25 PM 0
Share

Hey, thanks for the tip! Do you have any tips on sending arguments from code?

avatar image Dom3D · Dec 19, 2012 at 08:30 PM 1
Share

@AVividLight: you mean running a program that calls the player? Would that be a .Net application? Or another Unity player process?

avatar image AVividLight · Dec 20, 2012 at 04:25 AM 0
Share

Thanks for answering so quickly, Dom3D, and sorry it's taken me so long to respond!

It's a Unity Application, and I've tried using Process.Start (with arguments), and it's doesn't seem to work. $$anonymous$$aybe I need to try again, but do you have any tips?

avatar image AVividLight · Dec 20, 2012 at 05:38 PM 1
Share

I just got it working, thanks so much!

If anybody is wondering, to send the arguments, you must include "--args". example: Process.Start(path , "--args myArgument");

avatar image TechDevTom · Aug 13, 2020 at 08:58 PM 0
Share

This helped me a lot guys, thanks for this! I'm building a automation tool for building my apps for Android/iOS remotely, and needed to send in version numbers for the build process!

Show more comments

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

13 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How can I access Animator parameters in C# 2 Answers

Black And White To Colour Game Environment? 1 Answer

Is this a valid way to add a parameter to a class? 0 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