im trying to get this script to work, so when my game is showing info i wish to make the mouselook script stop working:
var Showing = false;
function Update () {
if(Showing) {
GetComponent(MouseLook).enabled = false;
}
else {
GetComponent(MouseLook).enabled = true;
}
}
i get the nice old “Object reference not set to an instance of an object”
haha indeed it is but usually when i search i get lots of craptackular, thanks again
!
erm, i still get the same error :S heres my code in JS:
function Update () {
if (Showing) {
var ML : MouseLook;
ML = gameObject.GetComponent("MouseLook");
ML.enabled = false;
}
}
i havn’t added anything to the C# script but im 100% sure its called MouseLook and defined as MouseLook in the script :\
Did you read the bit about, " First, make sure you’ve put the files in the right places per this document…:" It’s a few posts down from the top, “Posted: 03:54 PM 3 Days Ago”.
after following the instructions im under the impretion that "For example, if you want to create a Javascript that uses a C# script: place the C# script in the “Standard Assets” folder and the Javascript outside of the “Standard Assets” folder. The Javascript can now reference the C# script directly. "
my script is placed in its own folder outside of “standard assets” and the c# is in the standard assets :S im really not understanding why this is not working :. After playing around and moving the scripts to all sorts of places i got a different error “MouseLook” does not denote a valid type. could this be becuase im missing somthing?
Okay, so the files are in the right place now, that’s progress. Are both scripts attached to the same game object? If not, you’re going to need to Find() before you GetComponent().
Hey I’ve followed all your instructions but I’m still in the need of assistance. I did everything you said but I’m still getting an error. The premise of my code is for me to have in-game cheats so that testing is easier and more fun. I’ll type out each game object and then put the code beneath it. I know it’s really long, but hopefully you can understand whats going on 
Player
script name- scriptDevControls
var motor : CharacterMotor;
var itty : boolean;
var viewIsScaleable : boolean;
var thighBurn : boolean;
var canPixelate : boolean = false;
var pixelEffect : boolean;
private var cheat_Enabled : boolean = false;
private var input : String = "";
private var cheatCorrect : boolean;
function Start ()
{
motor = GetComponent(CharacterMotor);
var pixelEffect : SimplePixelizer;
pixelEffect = GameObject.FindGameObjectWithTag("MainCamera").GetComponent("SimplePixelizer");
}
function Update ()
{
if (Input.GetKeyUp(KeyCode.BackQuote)||Input.GetKeyUp(KeyCode.C))
{
if (cheat_Enabled == true)
{
input = "";
cheat_Enabled = false;
Time.timeScale = 1.0;
}
if (cheat_Enabled == false)
{
cheat_Enabled = true;
Time.timeScale = 0.0;
}
}
if (canPixelate == true)
{
pixelEffect.enabled = true;
}
else
{
pixelEffect.enabled = false;
}
}
function OnGUI ()
{
if (cheat_Enabled == true)
{
Time.timeScale = 0.0;
input = GUI.TextField (Rect(0,0,200,30),input,300);
if (GUI.Button (Rect(200,0,170,30), "Activate Cheat") || Input.GetKeyDown (KeyCode.Return))
{
if (input == "scrollo")
{
viewIsScaleable = true;
}
if (input == "flash")
{
motor.movement.maxSidewaysSpeed = 10;
motor.movement.maxBackwardsSpeed = 10;
Time.timeScale = 1.0;
cheatCorrect = true;
}
if (input == "thigh burn")
{
motor.jumping.baseHeight = 2;
motor.jumping.extraHeight = 4;
Time.timeScale = 1.0;
cheatCorrect = true;
}
if (input == "itty")
{
transform.localScale = Vector3(0.1,0.1,0.1);
itty = true;
Time.timeScale = 1.0;
}
if (input == ("pixy"))
{
canPixelate = true;
}
if (input == "reset")
{
motor.movement.maxSidewaysSpeed = 5;
motor.movement.maxBackwardsSpeed = 5;
motor.jumping.baseHeight = 1.1;
motor.jumping.extraHeight = 1.1;
transform.localScale = Vector3(0.3,0.3,0.3);
viewIsScaleable = false;
canPixelate = false;
Time.timeScale = 1.0;
if (itty == true)
{
transform.position.y += 1;
itty = false;
}
cheatCorrect = true;
}
if (input != "reset"||"space"||"speedy")
{
cheatCorrect = false;
}
if (cheatCorrect == false)
{
Time.timeScale = 1.0;
}
cheat_Enabled = false;
}
GUI.Box(Rect(0,0,Screen.width,Screen.height),"");
}
}
Camera
script name- SimplePixelizer
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/SimplePixelizer")]
public class SimplePixelizer : MonoBehaviour {
public bool colorBlending = false;
public int pixelize = 8;
//Fixed Resolution
//Enabling fixed resolution will ignore the pixelize variable.
//It won't ignore colorBlending
public bool useFixedResolution = false;
public int fixedHeight = 640;
public int fixedWidth = 480;
//Check if image effects are supported
protected void Start() {
if (!SystemInfo.supportsImageEffects) {
enabled = false;
return;
}
}
//Downgrade the image
void OnRenderImage (RenderTexture source, RenderTexture destination) {
//Create the buffer
RenderTexture buffer = null;
//Set the resolution of the buffer
if(useFixedResolution) {
buffer = RenderTexture.GetTemporary(fixedWidth, fixedHeight, 0);
}
else {
buffer = RenderTexture.GetTemporary(source.width/pixelize, source.height/pixelize, 0);
}
//Change filter mode of buffer to create the pixel effect
buffer.filterMode = FilterMode.Point;
//Change filter mode of source to disable color blending/merging
if(!colorBlending) {
source.filterMode = FilterMode.Point;
}
//Copy source to buffer to create the final image
Graphics.Blit(source, buffer);
//Copy buffer to destination so it renders on screen
Graphics.Blit(buffer, destination);
//Release buffer
RenderTexture.ReleaseTemporary(buffer);
}
}