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 /
  • Help Room /
avatar image
0
Question by podjigateligrey · Jul 28, 2021 at 03:35 PM · coroutinedictionaryarguments

How to add coroutines with an existing argument To a dictionary?

some thing like this doesn't work

 public Dictionary<string, Func<Vector3, IEnumerator>> URDD;
     private void Start()
     {
         URDD = new Dictionary<string, Func<Vector3, IEnumerator>>() {
             ["U"] = movePlayerUpCDirectionlist(Vector3.right)
     };
     }

and neither this

 Dictionary<string, Coroutine> UpD = new Dictionary<string, Coroutine>();
   Coroutine crt = StartCoroutine(movePlayerRightC(Vector3.right));

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
0
Best Answer

Answer by Hellium · Jul 28, 2021 at 04:05 PM

It should be either:

  private void Start()
  {
      URDD = new Dictionary<string, Func<Vector3, IEnumerator>>() {
          ["U"] = movePlayerUpCDirectionlist
      };
  }

And call StartCoroutine(URDD["U"](Vector3.right));

or

  private void Start()
  {
      URDD = new Dictionary<string, IEnumerator>() {
          ["U"] = movePlayerUpCDirectionlist(Vector3.right)
      };
  }

And call StartCoroutine(URDD["U"]);

Comment
Add comment · Show 4 · 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 podjigateligrey · Jul 29, 2021 at 04:45 AM 0
Share

it works without argument But it doesn't work with argument and I need with

avatar image Hellium · Jul 29, 2021 at 08:27 AM 0
Share

I've just tried the two snippets of code and they both work.

You haven't provided the definition of movePlayerUpCDirectionlist and not even explained what "does not work", so it's impossible to help you further.

avatar image podjigateligrey Hellium · Jul 29, 2021 at 02:31 PM 0
Share

there is an error here ["U"] = movePlayerUpCDirectionlist(Vector3.right) when I pass an argument And I saw the logic of the error Im passing just an argument but the dictionary's second parameter is a Function but never $$anonymous$$d I will just create an separate array of string And then will get from there a random index and with the help of "IF ELSE" will match index with my Coroutines Then just launch Coroutines like usual with an argument

avatar image Hellium podjigateligrey · Jul 29, 2021 at 03:25 PM 0
Share

I didn't put the declaration of the dictionary in the 2nd code snippet but obviously, the type of URDD should be Dictionary<string, IEnumerator>

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

175 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 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 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 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 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 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 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

How to force IEnumerator methods to be called only with StartCoroutine 2 Answers

Is there a way to check something every frame from within a coroutine? 1 Answer

Calling coroutine in a method issue. 1 Answer

Can WaitForSeconds run multiple times per frame? 1 Answer

Checking Internet inside a Coroutine 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