playMaker

Author Topic: Use LogError console warning.  (Read 2103 times)

pneill

  • Playmaker Newbie
  • *
  • Posts: 32
Use LogError console warning.
« on: June 14, 2012, 11:50:13 AM »
Was testing out the Sprite Manager 2 Actions from the wiki and I got a warning in the console


`HutongGames.PlayMaker.ActionHelpers.RuntimeError(HutongGames.PlayMaker.FsmStateAction, string)' is obsolete: `Use LogError instead.'

The code in question is..
Code: [Select]
public override void OnEnter()
{

if (cameraGameObject.Value.camera == null){
ActionHelpers.RuntimeError(this, "Not a camera!");
return;
}


I tried chaining RuntimeError to LogError, but it kicked an error.  What's the correct way to fix this?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Use LogError console warning.
« Reply #1 on: June 15, 2012, 06:32:19 AM »
Hi,

 Please find a corrected version. Tho I never actually succeeded in trigger errors. I am not too sure what I am doing wrong, but at least it will not output any warning and is actually updated with a Finish() call, which is how it should be anyway ( did that in my very early time with playmaker :) )

 I'll try to get to the bottom of this issue, it's not the first time I try tho.


Code: [Select]
// Author: Jean Fabre 2011
// Contact: http://www.fabrejean.net
// Online Help: https://hutonggames.fogbugz.com/default.asp?W634


using UnityEngine;


namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("SM2")]
[Tooltip("Sets the camera to use when calculating a pixel-perfect sprite size.")]
[HelpUrl("https://hutonggames.fogbugz.com/default.asp?W663")]
public class SM2SpriteSetCamera : FsmStateAction
{
[RequiredField]
[Tooltip("The game object to work with")]
public FsmOwnerDefault gameObject;

[RequiredField]
[Tooltip("The camera to use for calculation")]
public FsmGameObject cameraGameObject;

private SpriteRoot spriteRoot;

public override void Reset()
{
gameObject = null;
cameraGameObject = null;
}

public override void OnEnter()
{
// get the gameObject
GameObject go = gameObject.OwnerOption == OwnerDefaultOption.UseOwner ? Owner : gameObject.GameObject.Value;
// get the sprite attached to it.
spriteRoot = go.GetComponent<SpriteRoot>();


if (cameraGameObject.Value!=null)
{
if (cameraGameObject.Value.camera == null){
LogError("not a camera!");
}else{
DoSetCamera();
}
}
Finish();

}


private void DoSetCamera()
{
if (spriteRoot!=null){
spriteRoot.SetCamera(cameraGameObject.Value.camera);
}else{
LogError("not a sprite!");
}
}

}
}

 bye,

 Jean