Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class ComponentList : MonoBehaviour {
- // Step 1 - Add to Components Enum.
- // Step 2 - Add LevelComponent Instance. (In Unity)
- public EditorGlobals GlobalAccess;
- void Start()
- {
- // Required to have GlobalAccess
- GlobalAccess = GameObject.Find("EditorGlobals").GetComponent<EditorGlobals>();
- }
- public enum Components // Step 1
- {
- Diamond,
- SpikedDiamond,
- SolidBrick,
- GlassBrick,
- ColorSwitchBrick,
- ColorSwitchGate,
- ColorHazardBrick,
- ColorHazardGate,
- Fuse,
- HomingFuse,
- ClingingBombs,
- ClingingBrick,
- ElementalFire,
- ElementalLightning,
- ElementalFreeze,
- ColoredForceField,
- FieldSwitch,
- Generator,
- Wire,
- ElectricForceField
- }
- public string ComponentRealName(Components receiveComponent) // Step 2
- {
- return GlobalAccess.Components.RequestName(receiveComponent);
- }
- }
- [System.Serializable]
- public class LevelComponents // Be sure not to remove or edit any of these or their values will be lost in Unity.
- {
- public LevelComponent[] List; // Step 2 (In Unity)
- public EditorGlobals GlobalAccess;
- // Provides various information about requested component to UPDATE EditorGlobals.
- public void UpdateEditorGlobals(ComponentList.Components ComponentName)
- {
- foreach (LevelComponent LevelComponent in List)
- {
- if (LevelComponent.AttachedComponent == ComponentName)
- {
- GlobalAccess.OneSize = LevelComponent.OneSize;
- GlobalAccess.IsColored = LevelComponent.Colored;
- }
- }
- }
- // Returns the string name of requested component.
- public string RequestName(ComponentList.Components ComponentName)
- {
- string name = "No Matching Components";
- foreach (LevelComponent LevelComponent in List)
- {
- if (LevelComponent.AttachedComponent == ComponentName)
- {
- name = LevelComponent.Name;
- break;
- }
- }
- return name;
- }
- // Returns the GameObject of the requested component.
- public GameObject RequestGameObject(ComponentList.Components ComponentName)
- {
- GameObject returnObject = new GameObject();
- foreach (LevelComponent LevelComponent in List)
- {
- if (LevelComponent.AttachedComponent == ComponentName)
- {
- returnObject = LevelComponent.AttachedGameObject;
- break;
- }
- }
- return returnObject;
- }
- }
- [System.Serializable]
- public class LevelComponent // Be sure not to remove or edit any of these or their values will be lost in Unity.
- {
- public string Name;
- public ComponentList.Components AttachedComponent;
- public bool OneSize;
- public bool Colored;
- public GameObject AttachedGameObject;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement