Advertisement
CassataGames

Untitled

Sep 10th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.04 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class ComponentList : MonoBehaviour {
  5.  
  6.     // Step 1 - Add to Components Enum.
  7.     // Step 2 - Add LevelComponent Instance. (In Unity)
  8.  
  9.     public EditorGlobals GlobalAccess;
  10.     void Start()
  11.     {
  12.         // Required to have GlobalAccess
  13.         GlobalAccess = GameObject.Find("EditorGlobals").GetComponent<EditorGlobals>();
  14.     }
  15.  
  16.     public enum Components // Step 1
  17.     {
  18.         Diamond,
  19.         SpikedDiamond,
  20.         SolidBrick,
  21.         GlassBrick,
  22.         ColorSwitchBrick,
  23.         ColorSwitchGate,
  24.         ColorHazardBrick,
  25.         ColorHazardGate,
  26.         Fuse,
  27.         HomingFuse,
  28.         ClingingBombs,
  29.         ClingingBrick,
  30.         ElementalFire,
  31.         ElementalLightning,
  32.         ElementalFreeze,
  33.         ColoredForceField,
  34.         FieldSwitch,
  35.         Generator,
  36.         Wire,
  37.         ElectricForceField
  38.     }
  39.    
  40.     public string ComponentRealName(Components receiveComponent) // Step 2
  41.     {
  42.  
  43.         return GlobalAccess.Components.RequestName(receiveComponent);
  44.  
  45.     }
  46.  
  47. }
  48. [System.Serializable]
  49. public class LevelComponents // Be sure not to remove or edit any of these or their values will be lost in Unity.
  50. {
  51.     public LevelComponent[] List; // Step 2 (In Unity)
  52.     public EditorGlobals GlobalAccess;
  53.  
  54.     // Provides various information about requested component to UPDATE EditorGlobals.
  55.     public void UpdateEditorGlobals(ComponentList.Components ComponentName)
  56.     {
  57.         foreach (LevelComponent LevelComponent in List)
  58.         {
  59.             if (LevelComponent.AttachedComponent == ComponentName)
  60.             {
  61.                 GlobalAccess.OneSize = LevelComponent.OneSize;
  62.                 GlobalAccess.IsColored = LevelComponent.Colored;
  63.             }
  64.         }
  65.     }
  66.  
  67.     // Returns the string name of requested component.
  68.     public string RequestName(ComponentList.Components ComponentName)
  69.     {
  70.         string name = "No Matching Components";
  71.         foreach (LevelComponent LevelComponent in List)
  72.         {
  73.             if (LevelComponent.AttachedComponent == ComponentName)
  74.             {
  75.                 name = LevelComponent.Name;
  76.                 break;
  77.             }
  78.         }
  79.         return name;
  80.     }
  81.    
  82.     // Returns the GameObject of the requested component.
  83.     public GameObject RequestGameObject(ComponentList.Components ComponentName)
  84.     {
  85.         GameObject returnObject = new GameObject();
  86.         foreach (LevelComponent LevelComponent in List)
  87.         {
  88.             if (LevelComponent.AttachedComponent == ComponentName)
  89.             {
  90.                 returnObject = LevelComponent.AttachedGameObject;
  91.                 break;
  92.             }
  93.         }
  94.         return returnObject;
  95.     }
  96. }
  97. [System.Serializable]
  98. public class LevelComponent // Be sure not to remove or edit any of these or their values will be lost in Unity.
  99. {
  100.     public string Name;
  101.     public ComponentList.Components AttachedComponent;
  102.     public bool OneSize;
  103.     public bool Colored;
  104.     public GameObject AttachedGameObject;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement