add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class setGameObjectActiveState : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool setInitialState;
|
||||
public bool initialState;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool objectActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public GameObject objectToActive;
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
if (objectToActive == null) {
|
||||
objectToActive = gameObject;
|
||||
}
|
||||
|
||||
if (objectToActive.activeSelf) {
|
||||
objectActive = true;
|
||||
}
|
||||
|
||||
if (setInitialState) {
|
||||
setActiveState (initialState);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeActiveState ()
|
||||
{
|
||||
objectActive = !objectActive;
|
||||
|
||||
setActiveState (objectActive);
|
||||
}
|
||||
|
||||
public void setActiveState (bool state)
|
||||
{
|
||||
objectActive = state;
|
||||
|
||||
if (objectToActive.activeSelf != state) {
|
||||
objectToActive.SetActive (state);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeActiveStateFromEditor ()
|
||||
{
|
||||
changeActiveState ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Set GameObject Active State " + gameObject.name, gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user