I made this Enable/Disable custom action for my Object follow mouse component that I can switch on and off. You can customize it and enable/disable your component. Just change in this script Obj3DFollowCursor to your component name.
This custom action is based on Object:Visibility
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endifnamespace AC
{
[System.Serializable]
public class EnableDisableCompon : Action
{
// Declare variables here
public int parameterID = -1;
public int constantID = 0;
public bool affectChildren;
public EnableState enableStateObj = 0;
public GameObject objectToAffect;
public bool newEnableState;
public EnableDisableCompon ()
{
this.isDisplayed = true;
category = ActionCategory.Object;
title = "Enable-Disable Component";
description = "This is a blank Action template.";
}
override public void AssignValues (List<ActionParameter> parameters)
{
objectToAffect = AssignFile (parameters, parameterID, constantID, objectToAffect);
}
override public float Run ()
{
bool state = false;
if (enableStateObj == EnableState.Disabled)
{
state = true;
}
if (objectToAffect)
{
if (objectToAffect.GetComponent <Obj3DFollowCursor>())
{
objectToAffect.GetComponent <Obj3DFollowCursor>().enabled = !state;
}
else if (objectToAffect.GetComponent <Obj3DFollowCursor>())
{
objectToAffect.GetComponent <Obj3DFollowCursor>().enabled = state;
}
if (affectChildren)
{
foreach (Obj3DFollowCursor _ObjState in objectToAffect.GetComponentsInChildren <Obj3DFollowCursor>())
{
_ObjState.enabled = state;
}
}
}
return 0f;
}
#if UNITY_EDITOR
override public void ShowGUI (List<ActionParameter> parameters)
{
parameterID = Action.ChooseParameterGUI ("Object to affect:", parameters, parameterID, ParameterType.GameObject);
if (parameterID >= 0)
{
constantID = 0;
objectToAffect = null;
}
else
{
objectToAffect = (GameObject) EditorGUILayout.ObjectField
("Object to affect:", objectToAffect, typeof (GameObject), true);
constantID = FieldToID (objectToAffect, constantID);
objectToAffect = IDToField (objectToAffect, constantID, false);
}
enableStateObj = (EnableState) EditorGUILayout.EnumPopup ("Visibility:", enableStateObj);
affectChildren = EditorGUILayout.Toggle ("Affect children?", affectChildren);
AfterRunningOption ();
}
override public string SetLabel ()
{
string labelAdd = "";
if (objectToAffect)
labelAdd = " (" + objectToAffect.name + ")";
return labelAdd;
}
#endif }
}
Don't forget to add EnableState declaration to Enum.cs
just add this line at the bottom right after CheckVisState
public enum EnableState { Enabled, Disabled };
, and that should do.
Comments
And this is the only code I can pull from the plugin:
using UnityEngine;
namespace AmplifyBloom
{
[ExecuteInEditMode]
[System.Serializable]
[RequireComponent( typeof( Camera ) )]
[AddComponentMenu( "Image Effects/Amplify Bloom")]
public sealed class AmplifyBloomEffect : AmplifyBloomBase { }
}
If anyone can help it would be much appreciated.
Thanks,
Jason
The type or namespace name `enableState' could not be found. Are you missing a using directive or an assembly reference?