Exemplo n.º 1
0
 public static void initItem(IDevkitHierarchyItem item)
 {
     if (item.instanceID == 0u)
     {
         item.instanceID = LevelHierarchy.generateUniqueInstanceID();
     }
 }
Exemplo n.º 2
0
 protected static void triggerItemAdded(IDevkitHierarchyItem item)
 {
     if (LevelHierarchy.itemAdded != null)
     {
         LevelHierarchy.itemAdded(item);
     }
 }
 // Token: 0x06001131 RID: 4401 RVA: 0x00070F7C File Offset: 0x0006F37C
 protected void refresh()
 {
     this.itemsPanel.clearElements();
     for (int i = 0; i < LevelHierarchy.instance.items.Count; i++)
     {
         IDevkitHierarchyItem newItem             = LevelHierarchy.instance.items[i];
         HierarchyItemButton  hierarchyItemButton = new HierarchyItemButton(newItem);
         hierarchyItemButton.clicked += this.handleItemButtonClicked;
         this.itemsPanel.addElement(hierarchyItemButton);
     }
 }
Exemplo n.º 4
0
 protected static void triggerItemRemoved(IDevkitHierarchyItem item)
 {
     if (Level.isExiting)
     {
         return;
     }
     if (LevelHierarchy.itemRemoved != null)
     {
         LevelHierarchy.itemRemoved(item);
     }
 }
        // Token: 0x06001132 RID: 4402 RVA: 0x00070FEC File Offset: 0x0006F3EC
        protected void handleItemButtonClicked(Sleek2ImageButton button)
        {
            IDevkitHierarchyItem item = (button as HierarchyItemButton).item;

            InspectorWindow.inspect(item);
            Component component = item as Component;

            if (component != null)
            {
                DevkitSelectionManager.select(new DevkitSelection(component.gameObject, component.GetComponent <Collider>()));
            }
        }
Exemplo n.º 6
0
 public virtual void write(IFormattedFileWriter writer)
 {
     writer.writeValue <uint>("Available_Instance_ID", LevelHierarchy.availableInstanceID);
     writer.beginArray("Items");
     for (int i = 0; i < this.items.Count; i++)
     {
         writer.beginObject();
         IDevkitHierarchyItem devkitHierarchyItem = this.items[i];
         writer.writeValue <Type>("Type", devkitHierarchyItem.GetType());
         writer.writeValue <uint>("Instance_ID", devkitHierarchyItem.instanceID);
         writer.writeValue <IDevkitHierarchyItem>("Item", devkitHierarchyItem);
         writer.endObject();
     }
     writer.endArray();
 }
        // Token: 0x0600112D RID: 4397 RVA: 0x00070CC4 File Offset: 0x0006F0C4
        public HierarchyItemButton(IDevkitHierarchyItem newItem)
        {
            this.item = newItem;
            base.transform.anchorMin = new Vector2(0f, 1f);
            base.transform.anchorMax = new Vector2(1f, 1f);
            base.transform.pivot     = new Vector2(0.5f, 1f);
            base.transform.sizeDelta = new Vector2(0f, 30f);
            Sleek2TranslatedLabel sleek2TranslatedLabel = new Sleek2TranslatedLabel();

            sleek2TranslatedLabel.transform.reset();
            if (this.item is UnityEngine.Object)
            {
                sleek2TranslatedLabel.translation = new TranslatedTextFallback((this.item as UnityEngine.Object).name);
            }
            else
            {
                sleek2TranslatedLabel.translation = this.item.GetType().getTranslatedNameText();
            }
            sleek2TranslatedLabel.translation.format();
            sleek2TranslatedLabel.textComponent.color = Sleek2Config.darkTextColor;
            this.addElement(sleek2TranslatedLabel);
        }
Exemplo n.º 8
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();
        }
 // Token: 0x06001134 RID: 4404 RVA: 0x0007103C File Offset: 0x0006F43C
 protected virtual void handleItemRemoved(IDevkitHierarchyItem item)
 {
     this.refresh();
 }
Exemplo n.º 10
0
        public virtual void update()
        {
            if (this.copySelectionDelay.Count > 0)
            {
                DevkitSelectionManager.clear();
                foreach (GameObject newGameObject in this.copySelectionDelay)
                {
                    DevkitSelectionManager.add(new DevkitSelection(newGameObject, null));
                }
                this.copySelectionDelay.Clear();
            }
            if (!DevkitNavigation.isNavigating)
            {
                if (DevkitInput.canEditorReceiveInput)
                {
                    if (Input.GetKeyDown(113))
                    {
                        this.mode = DevkitSelectionTool.ESelectionMode.POSITION;
                    }
                    if (Input.GetKeyDown(119))
                    {
                        this.mode = DevkitSelectionTool.ESelectionMode.ROTATION;
                    }
                    if (Input.GetKeyDown(114))
                    {
                        this.mode = DevkitSelectionTool.ESelectionMode.SCALE;
                    }
                }
                Ray        pointerToWorldRay = DevkitInput.pointerToWorldRay;
                RaycastHit raycastHit;
                if (!Physics.Raycast(pointerToWorldRay, ref raycastHit, 8192f, RayMasks.LOGIC))
                {
                    Physics.Raycast(pointerToWorldRay, ref raycastHit, 8192f, (int)DevkitSelectionToolOptions.instance.selectionMask);
                    if (DevkitInput.canEditorReceiveInput && Input.GetKeyDown(101) && raycastHit.transform != null)
                    {
                        if (DevkitSelectionManager.selection.Count > 0)
                        {
                            this.handleTeleportTransformed(raycastHit.point, raycastHit.normal);
                        }
                        else
                        {
                            this.instantiate(raycastHit.point, raycastHit.normal);
                        }
                    }
                }
                if (DevkitInput.canEditorReceiveInput)
                {
                    if (Input.GetKeyDown(323))
                    {
                        this.drag = new DevkitSelection((!(raycastHit.transform != null)) ? null : raycastHit.transform.gameObject, raycastHit.collider);
                        if (this.drag.isValid)
                        {
                            DevkitSelectionManager.data.point = raycastHit.point;
                            this.isDragging = DevkitSelectionManager.beginDrag(this.drag);
                            if (this.isDragging)
                            {
                                DevkitTransactionManager.beginTransaction(new TranslatedText(new TranslationReference("#SDG::Devkit.Transactions.Transform")));
                                foreach (DevkitSelection devkitSelection in DevkitSelectionManager.selection)
                                {
                                    DevkitTransactionUtility.recordObjectDelta(devkitSelection.transform);
                                }
                            }
                        }
                        if (!this.isDragging)
                        {
                            DevkitSelectionManager.data.point = raycastHit.point;
                            this.beginAreaSelect     = DevkitInput.pointerViewportPoint;
                            this.beginAreaSelectTime = Time.time;
                        }
                    }
                    if (Input.GetKey(323) && !this.isDragging && !this.isAreaSelecting && Time.time - this.beginAreaSelectTime > 0.1f)
                    {
                        this.isAreaSelecting = true;
                        this.areaSelection.Clear();
                        if (!Input.GetKey(304) && !Input.GetKey(306))
                        {
                            DevkitSelectionManager.clear();
                        }
                    }
                }
                if (this.isDragging && this.drag.collider != null)
                {
                    DevkitSelectionManager.data.point = raycastHit.point;
                    DevkitSelectionManager.continueDrag(this.drag);
                }
                if (this.isAreaSelecting)
                {
                    Vector3 pointerViewportPoint = DevkitInput.pointerViewportPoint;
                    Vector2 vector;
                    Vector2 vector2;
                    if (pointerViewportPoint.x < this.beginAreaSelect.x)
                    {
                        vector.x  = pointerViewportPoint.x;
                        vector2.x = this.beginAreaSelect.x;
                    }
                    else
                    {
                        vector.x  = this.beginAreaSelect.x;
                        vector2.x = pointerViewportPoint.x;
                    }
                    if (pointerViewportPoint.y < this.beginAreaSelect.y)
                    {
                        vector.y  = pointerViewportPoint.y;
                        vector2.y = this.beginAreaSelect.y;
                    }
                    else
                    {
                        vector.y  = this.beginAreaSelect.y;
                        vector2.y = pointerViewportPoint.y;
                    }
                    int selectionMask = (int)DevkitSelectionToolOptions.instance.selectionMask;
                    foreach (IDevkitHierarchyItem devkitHierarchyItem in LevelHierarchy.instance.items)
                    {
                        int num = 1 << devkitHierarchyItem.areaSelectGameObject.layer;
                        if ((num & selectionMask) == num)
                        {
                            Vector3         vector3          = MainCamera.instance.WorldToViewportPoint(devkitHierarchyItem.areaSelectCenter);
                            DevkitSelection devkitSelection2 = new DevkitSelection(devkitHierarchyItem.areaSelectGameObject, null);
                            if (vector3.z > 0f && vector3.x > vector.x && vector3.x < vector2.x && vector3.y > vector.y && vector3.y < vector2.y)
                            {
                                if (!this.areaSelection.Contains(devkitSelection2))
                                {
                                    this.areaSelection.Add(devkitSelection2);
                                    DevkitSelectionManager.add(devkitSelection2);
                                }
                            }
                            else if (this.areaSelection.Contains(devkitSelection2))
                            {
                                this.areaSelection.Remove(devkitSelection2);
                                DevkitSelectionManager.remove(devkitSelection2);
                            }
                        }
                    }
                }
                if (Input.GetKeyUp(323))
                {
                    if (this.isDragging)
                    {
                        if (this.drag.isValid)
                        {
                            DevkitSelectionManager.data.point = raycastHit.point;
                            DevkitSelectionManager.endDrag(this.drag);
                        }
                        this.drag       = DevkitSelection.invalid;
                        this.isDragging = false;
                        this.transformSelection();
                        DevkitTransactionManager.endTransaction();
                    }
                    else if (this.isAreaSelecting)
                    {
                        this.isAreaSelecting = false;
                    }
                    else if (DevkitInput.canEditorReceiveInput)
                    {
                        DevkitSelectionManager.select(this.drag);
                    }
                }
                if (raycastHit.transform != this.hover.transform || raycastHit.collider != this.hover.collider)
                {
                    if (this.hover.isValid)
                    {
                        DevkitSelectionManager.data.point = raycastHit.point;
                        DevkitSelectionManager.endHover(this.hover);
                    }
                    this.hover.transform = raycastHit.transform;
                    this.hover.collider  = raycastHit.collider;
                    if (this.hover.isValid)
                    {
                        DevkitSelectionManager.data.point = raycastHit.point;
                        DevkitSelectionManager.beginHover(this.hover);
                    }
                }
            }
            if (DevkitSelectionManager.selection.Count > 0)
            {
                this.handlePosition = Vector3.zero;
                this.handleRotation = Quaternion.identity;
                bool flag = !DevkitSelectionToolOptions.instance.localSpace;
                foreach (DevkitSelection devkitSelection3 in DevkitSelectionManager.selection)
                {
                    if (!(devkitSelection3.gameObject == null))
                    {
                        this.handlePosition += devkitSelection3.transform.position;
                        if (!flag)
                        {
                            this.handleRotation = devkitSelection3.transform.rotation;
                            flag = true;
                        }
                    }
                }
                this.handlePosition /= (float)DevkitSelectionManager.selection.Count;
                this.positionGameObject.SetActive(this.mode == DevkitSelectionTool.ESelectionMode.POSITION);
                this.positionHandle.suggestTransform(this.handlePosition, this.handleRotation);
                this.rotationGameObject.SetActive(this.mode == DevkitSelectionTool.ESelectionMode.ROTATION);
                this.rotationHandle.suggestTransform(this.handlePosition, this.handleRotation);
                this.scaleGameObject.SetActive(this.mode == DevkitSelectionTool.ESelectionMode.SCALE);
                this.scaleHandle.suggestTransform(this.handlePosition, this.handleRotation);
                if (DevkitInput.canEditorReceiveInput)
                {
                    if (Input.GetKeyDown(99))
                    {
                        this.copyBuffer.Clear();
                        foreach (DevkitSelection devkitSelection4 in DevkitSelectionManager.selection)
                        {
                            this.copyBuffer.Add(devkitSelection4.gameObject);
                        }
                    }
                    if (Input.GetKeyDown(118))
                    {
                        TranslationReference newReference = new TranslationReference("#SDG::Devkit.Transactions.Paste");
                        TranslatedText       name         = new TranslatedText(newReference);
                        DevkitTransactionManager.beginTransaction(name);
                        foreach (GameObject gameObject in this.copyBuffer)
                        {
                            IDevkitSelectionCopyableHandler component = gameObject.GetComponent <IDevkitSelectionCopyableHandler>();
                            GameObject gameObject2;
                            if (component != null)
                            {
                                gameObject2 = component.copySelection();
                            }
                            else
                            {
                                gameObject2 = Object.Instantiate <GameObject>(gameObject);
                            }
                            IDevkitHierarchyItem component2 = gameObject2.GetComponent <IDevkitHierarchyItem>();
                            if (component2 != null)
                            {
                                component2.instanceID = LevelHierarchy.generateUniqueInstanceID();
                            }
                            DevkitTransactionUtility.recordInstantiation(gameObject2);
                            this.copySelectionDelay.Add(gameObject2);
                        }
                        DevkitTransactionManager.endTransaction();
                    }
                    if (Input.GetKeyDown(127))
                    {
                        TranslationReference newReference2 = new TranslationReference("#SDG::Devkit.Transactions.Delete_Selection");
                        TranslatedText       name2         = new TranslatedText(newReference2);
                        DevkitTransactionManager.beginTransaction(name2);
                        foreach (DevkitSelection devkitSelection5 in DevkitSelectionManager.selection)
                        {
                            DevkitTransactionUtility.recordDestruction(devkitSelection5.gameObject);
                        }
                        DevkitSelectionManager.clear();
                        DevkitTransactionManager.endTransaction();
                    }
                    if (Input.GetKeyDown(98))
                    {
                        this.referencePosition = this.handlePosition;
                        this.referenceRotation = this.handleRotation;
                        this.referenceScale    = Vector3.one;
                        this.hasReferenceScale = false;
                        if (DevkitSelectionManager.selection.Count == 1)
                        {
                            foreach (DevkitSelection devkitSelection6 in DevkitSelectionManager.selection)
                            {
                                if (!(devkitSelection6.gameObject == null))
                                {
                                    this.referenceScale    = devkitSelection6.transform.localScale;
                                    this.hasReferenceScale = true;
                                }
                            }
                        }
                    }
                    if (Input.GetKeyDown(110))
                    {
                        this.moveHandle(this.referencePosition, this.referenceRotation, this.referenceScale, true, this.hasReferenceScale && DevkitSelectionManager.selection.Count == 1);
                    }
                    if (Input.GetKeyDown(102))
                    {
                        List <Collider> list = ListPool <Collider> .claim();

                        List <Renderer> list2 = ListPool <Renderer> .claim();

                        Bounds bounds;
                        bounds..ctor(this.handlePosition, Vector3.zero);
                        foreach (DevkitSelection devkitSelection7 in DevkitSelectionManager.selection)
                        {
                            if (!(devkitSelection7.gameObject == null))
                            {
                                list.Clear();
                                devkitSelection7.gameObject.GetComponentsInChildren <Collider>(list);
                                foreach (Collider collider in list)
                                {
                                    bounds.Encapsulate(collider.bounds);
                                }
                                list2.Clear();
                                devkitSelection7.gameObject.GetComponentsInChildren <Renderer>(list2);
                                foreach (Renderer renderer in list2)
                                {
                                    bounds.Encapsulate(renderer.bounds);
                                }
                            }
                        }
                        ListPool <Collider> .release(list);

                        ListPool <Renderer> .release(list2);

                        DevkitNavigation.focus(bounds);
                    }
                }
            }
            else
            {
                this.positionGameObject.SetActive(false);
                this.rotationGameObject.SetActive(false);
                this.scaleGameObject.SetActive(false);
            }
        }
Exemplo n.º 11
0
 public static void removeItem(IDevkitHierarchyItem item)
 {
     LevelHierarchy.instance.items.Remove(item);
     LevelHierarchy.triggerItemRemoved(item);
 }
Exemplo n.º 12
0
 public static void addItem(IDevkitHierarchyItem item)
 {
     LevelHierarchy.instance.items.Add(item);
     LevelHierarchy.triggerItemAdded(item);
 }