Beispiel #1
0
 public static ObjectReferenceManager get()
 {
     if (instance == null)
     {
         instance = new GameObject("ObjectReferenceManager").AddComponent <ObjectReferenceManager>();
         instance.gameObject.hideFlags = HideFlags.HideInHierarchy;
     }
     return(instance);
 }
Beispiel #2
0
 public ObjectReferenceManager()
 {
     if (instance == null)
     {
         instance = this;
     }
     if (references == null)
     {
         references = new ReferenceDictionary();
     }
 }
Beispiel #3
0
    public override void doGUI()
    {
        base.doGUI();
        status = UnityEditor.EditorGUILayout.Foldout(status, "Points");

        if (status)
        {
            size = UnityEditor.EditorGUILayout.IntField("Size:", getPoints().Count);
            if (size < getPoints().Count)
            {
                getPoints().RemoveRange(size, getPoints().Count - size);
                string[] temp = new string[size];
                Array.Copy(pointsPaths, 0, temp, 0, size);
                pointsPaths = temp;
            }

            else if (size > getPoints().Count)
            {
                while (size > getPoints().Count)
                {
                    getPoints().Add(null);
                }
                string[] temp = new string[size];
                if (pointsPaths.Length != 0)
                {
                    Array.Copy(pointsPaths, 0, temp, 0, pointsPaths.Length - 1);
                }
                for (int i = pointsPaths.Length; i < size; i++)
                {
                    temp[i] = null;
                }
                pointsPaths = temp;
            }

            for (int i = 0; i < getPoints().Count; i++)
            {
                getPoints()[i] = ((Label)UnityEditor.EditorGUILayout.ObjectField(getPoints()[i], typeof(Label), true));
                if (getPoints()[i] != null)
                {
                    ObjectReferenceManager.get().deleteReference(getPointsPaths()[i]);
                    getPointsPaths()[i] = ObjectReferenceManager.get().addReference(getPoints()[i]);
                }
            }
        }
    }
Beispiel #4
0
 public List <Label> getPoints()
 {
     if (points == null || points.Count < getPointsPaths().Length)
     {
         points = new List <Label>();
         foreach (string id in getPointsPaths())
         {
             if (id == null)
             {
                 points.Add(null);
             }
             else
             {
                 points.Add(ObjectReferenceManager.get().fetchReference <Label>(id));
             }
         }
     }
     return(points);
 }