public int GetObjectCount(LevelEditorIdentifier id)
        {
            if (objectCount.TryGetValue(id, out int count))
            {
                return(count);
            }

            Debug.LogError("No object with the ID " + id + ".");
            return(0);
        }
 public DeleteObjectUndoAction(ILevelEditorObject obj)
 {
     targetId         = obj.ID;
     targetInstanceId = obj.InstanceID;
     IExposedToLevelEditor[] exposed = obj.GetExposedComponents();
     savedValues = new IExposedWrapper[exposed.Length];
     for (int i = 0; i < exposed.Length; i++)
     {
         savedValues[i] = exposed[i].GetWrapper();
     }
 }
Example #3
0
        public LevelEditorObjectData(ILevelEditorObject obj)
        {
            name       = obj.MyGameObject.name;
            active     = obj.MyGameObject.activeSelf;
            id         = obj.ID;
            instanceId = obj.InstanceID;

            IExposedToLevelEditor[] objComps = obj.GetExposedComponents();
            components = new LevelEditorComponentData[objComps.Length];
            for (int i = 0; i < objComps.Length; i++)
            {
                components[i] = new LevelEditorComponentData(objComps[i]);
            }
        }
 public LevelEditorResource(LevelEditorResource copy)
 {
     name       = copy.name;
     id         = copy.id;
     customIcon = copy.customIcon;
     icon       = copy.icon;
     limit      = copy.limit;
     hidden     = copy.hidden;
     asset      = copy.asset;
     treeID     = copy.treeID;
     treeDepth  = copy.treeDepth;
     parent     = copy.parent;
     children   = copy.children;
 }
        public LevelEditorObjectData Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options)
        {
            options.Security.DepthStep(ref reader);

            string name              = null;
            bool   active            = false;
            LevelEditorIdentifier id = new LevelEditorIdentifier();
            uint instanceId          = 0;

            LevelEditorComponentData[] components = null;

#if ALE_COMPATIBILITY_0
            if (options is LevelEditorSerializerOptions levelEditorOptions && levelEditorOptions.SaveVersion == 0)
            {
                DeserializeFormat0(ref reader, options, ref name, ref active, ref id, ref instanceId, ref components);
            }
        public static int GetItemIndex(this ILevelEditorResources x, LevelEditorIdentifier identifier)
        {
            IReadOnlyList <ILevelEditorResource> resources = x.GetResources();

            if (resources != null && resources.Count > 0)
            {
                for (int i = 0; i < resources.Count; i++)
                {
                    if (resources[i].ID == identifier)
                    {
                        return(i);
                    }
                }

                throw new ArgumentException($"There's no resource with the ID {identifier}.");
            }

            throw new EmptyArrayException("There are no resources to get.");
        }
        public static ILevelEditorResource GetResource(this ILevelEditorResources x, LevelEditorIdentifier identifier)
        {
            IReadOnlyList <ILevelEditorResource> resources = x.GetResources();

            if (resources != null && resources.Count > 0)
            {
                for (int i = 0; i < resources.Count; i++)
                {
                    if (resources[i].ID == identifier)
                    {
                        return(resources[i]);
                    }
                }

                Debug.LogError($"There's no resource with the ID {identifier}.");
                return(null);
            }

            throw new EmptyArrayException("There are no resources to get.");
        }
 public static ILevelEditorObject CreateObject(this ILevelEditorObjectManager x, LevelEditorIdentifier identifier, Vector3 position, uint instanceID, bool registerUndo = true)
 {
     return(x.CreateObject(x.GetResource(identifier), position, Quaternion.identity, null, instanceID, registerUndo));
 }
 public static ILevelEditorObject CreateObject(this ILevelEditorObjectManager x, LevelEditorIdentifier identifier, Vector3 position, Transform parent, bool registerUndo = true)
 {
     return(x.CreateObject(x.GetResource(identifier), position, Quaternion.identity, parent, x.GetNextInstanceID(), registerUndo));
 }
 public static ILevelEditorObject CreateObject(this ILevelEditorObjectManager x, LevelEditorIdentifier identifier, bool registerUndo = true)
 {
     return(x.CreateObject(x.GetResource(identifier), Vector3.zero, Quaternion.identity, null, x.GetNextInstanceID(), registerUndo));
 }
 public static ILevelEditorObject CreateObject(this ILevelEditorObjectManager x, LevelEditorIdentifier identifier, Transform parent, uint instanceID, bool registerUndo = true)
 {
     return(x.CreateObject(x.GetResource(identifier), Vector3.zero, Quaternion.identity, parent, instanceID, registerUndo));
 }
 public static ILevelEditorResource GetResource(this ILevelEditorObjectManager x, LevelEditorIdentifier identifier)
 {
     return(x.Resources.GetResource(identifier));
 }