コード例 #1
0
        public static void WriteDefensesLayout(BaseDescription baseDesription)
        {
            var layoutObjects = UnityEngine.Object.FindObjectsOfType <LayoutObject>();
            var objectId      = 1;

            foreach (var obj in layoutObjects)
            {
                var objectIdentity = obj.GetComponent <ObjectIdentity>();
                objectIdentity.RuntimeId = objectId++;

                baseDesription.AddToLayout(objectIdentity);

                var additionalData = obj.GetComponent <AdditionalDataProvider>();
                if (additionalData != null)
                {
                    baseDesription.AddAdditionalData(additionalData);
                }
            }

            //In case some objects have dependencies on each other, destroy them afterwards
            foreach (var layoutObject in layoutObjects)
            {
                UnityEngine.Object.DestroyImmediate(layoutObject.gameObject);
            }
        }
コード例 #2
0
        private void UpdateBaseLayout()
        {
            currentBaseDescription.layout.Clear();
            foreach (var item in layoutObjects)
            {
                currentBaseDescription.AddToLayout(item);

                var additionalData = item.GetComponent <AdditionalDataProvider>();
                if (additionalData != null)
                {
                    currentBaseDescription.AddAdditionalData(additionalData);
                }
            }
        }