playMaker

Author Topic: Error using StartCoroutine() within action[WONTFIX]  (Read 826 times)

celaeno

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Error using StartCoroutine() within action[WONTFIX]
« on: March 10, 2016, 05:18:28 AM »
Hello I get this error when using StartCoroutine()

Quote
Assets/PlayMaker/Actions/Puzzle Game/FindNeighbours.cs(126,33): error CS0119: Expression denotes a `type', where a `variable', `value' or `method group' was expected

Is it possible or how can I use StartCoroutine() within an action?

Thanks


Code: [Select]
using UnityEngine;
using System.Collections;
using System.Collections.Generic;


public class FindNeighbours : FsmStateAction


   public override void OnEnter()
     Debug.Log ("About to StartCoroutine");
     StartCoroutine(TestCoroutine());
     Debug.Log ("Back from StartCoroutine");
   }
   IEnumerator TestCoroutine(){
     Debug.Log ("about to yield return WaitForSeconds(1)");
     yield return new WaitForSeconds(1);
     Debug.Log ("Just waited 1 second");
     yield return new WaitForSeconds(1);
     Debug.Log ("Just waited another second");
     yield break;
     Debug.Log ("You'll never see this"); // produces a dead code warning
   }
 }





« Last Edit: March 24, 2016, 11:39:15 PM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14198
  • Official Playmaker Support
    • View Profile
Re: Error using StartCoroutine() within action
« Reply #1 on: March 10, 2016, 06:17:28 AM »
Hi,

 Unfortunatly no, because an action is not a MonoBehavior it doesn't implement the internal necessary apis for coroutine to be executed and handled properly.

Typically, either you create your custom coroutine system ( like you would when creating editor windows and tools, which also lack coroutines), or you save the Ienumerator of the function you want to "coroute" and handle it manually.

Bye,

 Jean

celaeno

  • Playmaker Newbie
  • *
  • Posts: 5
    • View Profile
Re: Error using StartCoroutine() within action
« Reply #2 on: March 10, 2016, 11:22:34 AM »
Oke thanks for your help  :)