Find Game Object by name, or by what object dragged in the Inspector, then to either set it Active(true) or false.
/*
*
* Adventure Creator
* by Chris Burton, 2013-2014
*
* "ActionSendMessage.cs"
*
* This action calls "SendMessage" on a GameObject.
* Both standard messages, and custom ones with paremeters, can be sent.
*
*/
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using AC;
#if UNITY_EDITOR
using UnityEditor;
#endif[System.Serializable]
public class ActionSetActive : Action
{
public int constantID = 0;
public int parameterID = -1;
public GameObject linkedObject;
public string WhichName = null; // to be used for whichever object to be found by name.
public ActionSetActive ()
{
this.isDisplayed = true;
title = "Object: Set Active";
}
override public void AssignValues (List<ActionParameter> parameters)
{
linkedObject = AssignFile (parameters, parameterID, constantID, linkedObject);
}
override public float Run ()
{
if (linkedObject)
{
linkedObject.SetActive(true);
}
return 0f;
}
override public int End (List<AC.Action> actions)
{
// If the linkedObject is an immediately-starting ActionList, don't end the cutscene
if (linkedObject && linkedObject.GetComponent <Cutscene>())
{
Cutscene tempAction = linkedObject.GetComponent<Cutscene>();
if (tempAction.triggerTime == 0f)
{
return -2;
}
}
return (base.End(actions));
}
#if UNITY_EDITOR
public override void ShowGUI (List<ActionParameter> parameters)
{
parameterID = ChooseParameterGUI ("Object to affect:", parameters, parameterID, ParameterType.GameObject);
if (parameterID >= 0)
{
constantID = 0;
linkedObject = null;
}
else
{
linkedObject = (GameObject) EditorGUILayout.ObjectField ("Object to affect:", linkedObject, typeof(GameObject), true);
constantID = FieldToID (linkedObject, constantID);
linkedObject = IDToField (linkedObject, constantID, false);
}
AfterRunningOption ();
}
#endif
}