using System.Collections.Generic;
using UnityEngine;
public class SwtichName : MonoBehaviour
{
[SerializeField]
[Space(5)]
[Header("Rotation Mode")]
public bool individualRotation = false;
private void Start()
{
}
// Update is called once per frame
void Update()
{
if (globalRotation == false)
{
// Name in inspector should be individualRotation
}
else
{
// Name in inspector should be globalRotation
}
}
}
I want to switch the string name of the variable in the Update when checking/unchecking the variable:
public bool individualRotation = false;
If not checked(false) the name should be individualRotation.
But if checked(true) i want that the name will be globalRotation.
using System.Collections.Generic;
using UnityEngine;
public class SwtichName : MonoBehaviour
{
public enum RotationMode
{
Individual,
Global
}
public RotationMode rotationMode;
private void Start()
{
}
}
And how do i change the variable name ?
I have a bool variable name individualRotation
How do i change it’s name to Individual or Global ?
I can use switch and case but how do i change the variable name ?
Why do you need two of them? It’s a boolean! It has 2 possible values. Why do you never use the other one?
If individualRotation is true then does that not nean globalRotation is false?
There, I’ll do some more spoonfeeding:
Your (recommended) new update():
// Update is called once per frame
void Update()
{
if (individualRotation== true)//this means globalRotation is false
{
// Name in inspector should be individualRotation <- NO! NO! Bad newbie programmer! Bad!
}
else//this means globalRotation is true
{
// Name in inspector should be globalRotation <- NO! NO! Bad newbie programmer! Bad!
}
}