public static void beginGenericTransaction()
        {
            TranslatedText translatedText = new TranslatedText(new TranslationReference("SDG", "Devkit.Transactions.Generic"));

            translatedText.format();
            DevkitTransactionManager.beginTransaction(translatedText);
        }
Пример #2
0
        public static void instantiate(ObjectAsset asset, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (asset == null)
            {
                return;
            }
            if (!Level.isEditor)
            {
                return;
            }
            TranslationReference newReference   = new TranslationReference("#SDG::Devkit.Transactions.Spawn");
            TranslatedText       translatedText = new TranslatedText(newReference);

            translatedText.format(asset.objectName);
            DevkitTransactionManager.beginTransaction(translatedText);
            DevkitHierarchyWorldObject devkitHierarchyWorldObject = LevelObjects.addDevkitObject(asset.GUID, position, rotation, scale, ELevelObjectPlacementOrigin.MANUAL);

            DevkitTransactionUtility.recordInstantiation(devkitHierarchyWorldObject.gameObject);
            DevkitTransactionManager.endTransaction();
        }
Пример #3
0
        public static void instantiate(Type type, Vector3 position, Quaternion rotation, Vector3 scale)
        {
            if (!Level.isEditor)
            {
                return;
            }
            TranslationReference newReference   = new TranslationReference("#SDG::Devkit.Transactions.Spawn");
            TranslatedText       translatedText = new TranslatedText(newReference);

            translatedText.format(type.Name);
            DevkitTransactionManager.beginTransaction(translatedText);
            IDevkitHierarchySpawnable devkitHierarchySpawnable;

            if (typeof(MonoBehaviour).IsAssignableFrom(type))
            {
                GameObject gameObject = new GameObject();
                gameObject.name = type.Name;
                gameObject.transform.position   = position;
                gameObject.transform.rotation   = rotation;
                gameObject.transform.localScale = scale;
                DevkitTransactionUtility.recordInstantiation(gameObject);
                devkitHierarchySpawnable = (gameObject.AddComponent(type) as IDevkitHierarchySpawnable);
            }
            else
            {
                devkitHierarchySpawnable = (Activator.CreateInstance(type) as IDevkitHierarchySpawnable);
            }
            if (devkitHierarchySpawnable != null)
            {
                devkitHierarchySpawnable.devkitHierarchySpawn();
            }
            IDevkitHierarchyItem devkitHierarchyItem = devkitHierarchySpawnable as IDevkitHierarchyItem;

            if (devkitHierarchyItem != null)
            {
                LevelHierarchy.initItem(devkitHierarchyItem);
            }
            DevkitTransactionManager.endTransaction();
        }