Erroor message I dont understand

I was checking out the GUI tut from Unitytutoials.com and I picked up this weird error message after adding right mouse click capability:

!IsActive ()  !m_RunInEditMode
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UnityEngine.GameObject:SendMessage(String, Object, SendMessageOptions)
UnityEngine.MouseOverPair:SendMessage(String) (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Runtime\Export\MouseEvents.cs:17)
UnityEngine.SendMouseEvents:smile:oSendMouseEvents() (at C:\builds\unity-branches-2.5.x\unity-2.5.x\Runtime\Export\MouseEvents.cs:129)

[..\..\Runtime\Mono\MonoBehaviour.cpp line 842]

Does anyone know what this means?
Thanxs for your time :slight_smile:

Yes, it’s an error generated from inside Unity itself (ie, not your code) - please file a bug report about this. Post again if this error is actually stopping you from making progress, and I’ll see if there is any workaround.

I’m getting much of the same error.
Specifically, I have a DamageDealer script attached to something with collision.
It calls SendMessageUpwards() on the gameObject of whatever it collides with; this message ends up in a DamageTaker script.
The DamageTaker script then calls BroadcastMessage(“Die”, null) on its own gameObject.
Inside that BroadcastMessage callback, I get this error/assert message.

I don’t get this message in build-and-run mode (that I can see, but maybe it’s just swallowed), only in run-inside-editor mode. It’s stopping me from making progress, because I always keep “pause on error” on so as to take care of any problems ASAP.

I’m using 2.6.1f3 (31223)

Here’s the DamageTaker script, which is where the error happens (the call to BroadcastMessage in TakeDamage):

using UnityEngine;
using System.Collections;

public class DamageTaker : MonoBehaviour {

	public float hitPoints = 1.0f;
	private float actualHitPoints;
	
	public void Start() {
		Debug.Log("DamageTaker.Start() " + gameObject.name);
		actualHitPoints = hitPoints;
	}
	
	public void TakeDamage(float amt) {
		actualHitPoints -= amt;
		Debug.Log("DamageTaker.TakeDamage() " + gameObject.name);
		if (actualHitPoints <= 0) {
			if (gameObject.active) {
				gameObject.BroadcastMessage("Die", null);
			}
			//	todo: create particle system, sound, etc
		}
	}
	
	public void Die() {
		if (gameObject.active) {
			gameObject.active = false;
			enabled = false;
			Destroy(gameObject);
		}
	}
}

Here’s the DamageDealer script, which calls SendMessageUpwards() on the mesh object that is inside the prefab object that was spawned:

using UnityEngine;
using System.Collections;

public class DamageDealer : MonoBehaviour {

	public float damageAmount = 1.0f;
	
	void OnCollisionEnter(Collision c) {
		Debug.Log("DamageDealer.OnCollisionEnter() " + c.gameObject.name);
		c.gameObject.SendMessageUpwards("TakeDamage", damageAmount);
		gameObject.BroadcastMessage("Die", null, SendMessageOptions.DontRequireReceiver);
	}
	
	public void Die() {
		if (gameObject.active) {
			gameObject.active = false;
			enabled = false;
			Destroy(gameObject);
		}
	}
}

Here’s how I spawn the thing getting hit, specifically look at SpawnAtTargeting():

using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class SpawnStringScript : MonoBehaviour {

	public GameObject toSpawn = null;
	public int numSpawned = 8;
	public float spacing = 5.0f;
	
	public int numTimesSpawning = 1;
	public float delayBetweenSpawns = 30;
	public float timeUntilFirstSpawn = 1;

	float timeUntilSpawn;
	int timesToSpawn;

	Vector3 GetNavpoint() {
		foreach (Transform t in gameObject.transform) {
			return t.position;
		}
		return new Vector3(0, 0, 0);
	}

	// Use this for initialization
	void Start () {
		timeUntilSpawn = timeUntilFirstSpawn;
		timesToSpawn = numTimesSpawning;
	}
	
	void Spawn() {
		SpawnAtTargeting(gameObject.transform.position, GetNavpoint());
	}
	
	void SpawnAt(Vector3 pos) {
		SpawnAtTargeting(pos, GetNavpoint());
	}
	
	void SpawnAtTargeting(Vector3 pos, Vector3 tgt) {
		Debug.Log(String.Format("SpawnAtTargeting({0}, {1}, {2})", pos, tgt, toSpawn));
		Vector3 d = (pos - tgt);
		d.Normalize();
		GameObject go = new GameObject();
		go.active = true;
		StringController sc = go.AddComponent("StringController") as StringController;
		sc.spacing = spacing;
		sc.pathParent = gameObject.transform;
		Quaternion q = new Quaternion();
		q.SetFromToRotation(new Vector3(0, 0, 1), d);
		for (int i = 0; i < numSpawned; ++i) {
			GameObject obj = (GameObject)GameObject.Instantiate(toSpawn, pos, q);
			sc.Add(obj);
			pos = pos + (d * spacing);
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (timesToSpawn > 0) {
			timeUntilSpawn -= Time.deltaTime;
			if (timeUntilSpawn <= 0) {
				timeUntilSpawn += delayBetweenSpawns;
				timesToSpawn -= 1;
				Spawn();
			}
		}
	}
}

Here’s how I spawn the thing doing the colliding, specifically look at Update() (ought to be factored, I know :-):

using UnityEngine;
using System.Collections;

public class Player2DScript : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	public float posX = -10;
	public float posZ = -10;
	public float hMoveSpeed = 10;
	public float hiLimitX = 20;
	public float loLimitX = -20;
	
	public Transform laserPrefab = null;
	public float shotInterval = 0.5f;
	public float laserVelocity = 20.0f;
	private float timeToNextShot = 0.5f;
	
	// Update is called once per frame
	void Update () {
		float hMove = Input.GetAxis("Horizontal");
		posX += hMove * hMoveSpeed * Time.deltaTime;
		if (posX > hiLimitX)
			posX = hiLimitX;
		if (posX < loLimitX)
			posX = loLimitX;
		transform.position = new Vector3(posX, 0, posZ);
		if (timeToNextShot > 0) {
			timeToNextShot -= Time.deltaTime;
		}
		if ((timeToNextShot <= 0)  Input.GetButton("Fire1")) {
			Debug.Log("Fire triggered");
			timeToNextShot = shotInterval;
			GameObject bullet = (GameObject)GameObject.Instantiate(laserPrefab,
				new Vector3(transform.position.x, transform.position.y, transform.position.z + 4),
				Quaternion.AngleAxis(90, Vector3.right));
			bullet.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, laserVelocity);
		}
	}
}

Finally, here is the full error/stack message:

!IsActive ()  !m_RunInEditMode
UnityEngine.GameObject:BroadcastMessage(String, Object, SendMessageOptions)
UnityEngine.GameObject:BroadcastMessage(String, Object, SendMessageOptions)
UnityEngine.GameObject:BroadcastMessage(String, Object)
DamageTaker:TakeDamage(Single) (at Assets\Scripts\DamageTaker.cs:19)
UnityEngine.GameObject:SendMessageUpwards(String, Object, SendMessageOptions)
UnityEngine.GameObject:SendMessageUpwards(String, Object, SendMessageOptions)
UnityEngine.GameObject:SendMessageUpwards(String, Object)
DamageDealer:OnCollisionEnter(Collision) (at Assets\Scripts\DamageDealer.cs:10)

[..\..\Runtime\Mono\MonoBehaviour.cpp line 808]

I receive this error message 100% when going from the front end scene of our game into a level scene. There is no callstack in the console window; just the one line. The status bar reads:

Assert in file: /Applications/buildAgent/…/Runtime/Mono/MonoBehaviour.cpp at line: 470.

It happens constantly - if not every frame, something close to that. Since this is an existing project that was upgraded to Unity 3 yesterday, I can’t point to any one change that caused it.

I experience same problem.

!IsActive () !m_RunInEditMode

This error constantly happen.

but I can make progress on my project and play game in editor mode,

But I can’t make build.

Is this 3.0 itself’s problem?

Any thoughts yet? I’m able to build and run just fine. Just no “error on pause” functionality for mee. :frowning:

I solved this. It is because of 2.6 version’ decal framework. Maybe update that middleware solve problem. Or just delete it.

:face_with_spiral_eyes:I think it has something to do with this code: (This is when the error pauses in the console)

//@script ExecuteInEditMode()

var GameOverBG : GUITexture;
var mySkin : GUISkin;
var mySkin2 : GUISkin;
var mySkin3 : GUISkin;
var plunger : GameObject;
var MessageCenter : GUIText;
var highScoreRank = 0;


//this script is used to keep track of the score of the game and the remaining lives

//varible to hold how many points do we have
var scorePoints :float = 0;
//variable to hold how many lives do we have
var lives :float = 0;
//variable to hold if its game over
private var showGameOver :boolean = false;
//var flipperKicks :AudioClip;

function Start(){
	GameOverBG.gameObject.active = false;
}

function FixedUpdate()
{
	//if lives equal 0 , then game over
	if(lives == -1)
	{
		showGameOver = true;
		ReloadLevel();
	}
}

function OnGUI (){	
	GUI.skin = mySkin;
	GUI.Label (Rect (Screen.width / 2 - 175, Screen.height / 2 - 228, 320, 75), scorePoints.ToString());
	GUI.skin = mySkin3;
	GUI.Label (Rect (Screen.width / 2 - 155, Screen.height / 2 - 238, 320, 75), "Balls Left: " + lives.ToString());
	
	//if its gameover show the game over window
	if(showGameOver)
	{
		MessageCenter.text = "";
		lives = 0;
		plunger.gameObject.active = false;
		GameOverBG.gameObject.active = true;
		GUI.skin = mySkin2;
		GUI.Label (Rect (Screen.width / 2 + 115, Screen.height / 2 - 50, 320, 75), ("GAME OVER"));
		GUI.Label (Rect (Screen.width / 2 + 128, Screen.height / 2 - 100, 300, 300), ("YOUR SCORE: " + scorePoints.ToString()));
	}
}

function ReloadLevel()
{
	//if its game over, wait 5 seconds and then reload the level
	if(showGameOver){
		PlayerPrefs.SetInt("PlayerScore", scorePoints);
		checkHighScore();
		if (highScoreRank != 11){
			yield new WaitForSeconds (5);
			Application.LoadLevel("HighScoreSubmission");
		} else {
			yield new WaitForSeconds (5);
			Application.LoadLevel("MainMenu");
		}
	}
}

function AddToScore(){
	scorePoints += 100;
}

function RemoveLife(){
	lives -= 1;
}


function checkHighScore(){
   
   // load letest scores
   names = new String[10];
   names[0] = PlayerPrefs.GetString("leaderboard1");         
   names[1] = PlayerPrefs.GetString("leaderboard2");         
   names[2] = PlayerPrefs.GetString("leaderboard3");   
   names[3] = PlayerPrefs.GetString("leaderboard4");
   names[4] = PlayerPrefs.GetString("leaderboard5");
   names[5] = PlayerPrefs.GetString("leaderboard6");
   names[6] = PlayerPrefs.GetString("leaderboard7");
   names[7] = PlayerPrefs.GetString("leaderboard8");
   names[8] = PlayerPrefs.GetString("leaderboard9");   
   names[9] = PlayerPrefs.GetString("leaderboard10");

   scores= new int[10];
   scores[0] = PlayerPrefs.GetInt("leaderboardScore1");               
   scores[1] = PlayerPrefs.GetInt("leaderboardScore2");                   
   scores[2] = PlayerPrefs.GetInt("leaderboardScore3");
   scores[3] = PlayerPrefs.GetInt("leaderboardScore4");
   scores[4] = PlayerPrefs.GetInt("leaderboardScore5");
   scores[5] = PlayerPrefs.GetInt("leaderboardScore6");    
   scores[6] = PlayerPrefs.GetInt("leaderboardScore7");
   scores[7] = PlayerPrefs.GetInt("leaderboardScore8");
   scores[8] = PlayerPrefs.GetInt("leaderboardScore9");    
   scores[9] = PlayerPrefs.GetInt("leaderboardScore10");
   
   theScore = PlayerPrefs.GetInt("PlayerScore");
   
   rank = 11;
   
   // find our rank on the scoreboard
   for(i=9; i>-1; --i){
      if(scores[i]<=theScore){
         rank=i;
      }
   }
   
   highScoreRank = (rank);
   
   
  }

The only 3rd party frameworks i am currently using and installed are: (So i can’t really delete these at the moment)

  • iTween
  • iTween visual editor

I guess my real worry (This being my first app store submission) Will i get canned for this type of error? From what i can tell, this specific error really doesn’t goof anything up.

hrmmm…

Avast, i think me found it, got rid of:

plunger.gameObject.active = false;

Guessing it may be already false er something. Investigation continues.

I also found a possible solution to the problem.

http://answers.unity3d.com/questions/28342/how-can-i-remove-constant-errors-from-the-editorwindow

Because “iTween visual editor”
When I SetActiveRecursively the object is to remind.
but,nothing happened