Exemplo n.º 1
0
 private static UnityEngine.Object ValidateObjectForPackableFieldAssignment(UnityEngine.Object[] references, Type objType, SerializedProperty property, EditorGUI.ObjectFieldValidatorOptions options)
 {
     UnityEngine.Object result;
     if (references.Length > 0 && SpriteAtlasInspector.IsPackable(references[0]))
     {
         result = references[0];
     }
     else
     {
         result = null;
     }
     return(result);
 }
Exemplo n.º 2
0
        private void HandlePackableListUI()
        {
            Event current         = Event.current;
            bool  flag            = false;
            Rect  controlRect     = EditorGUILayout.GetControlRect(new GUILayoutOption[0]);
            int   s_LastControlID = EditorGUIUtility.s_LastControlID;

            switch (current.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (controlRect.Contains(current.mousePosition) && GUI.enabled)
                {
                    bool flag2 = false;
                    UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
                    UnityEngine.Object[] array            = objectReferences;
                    for (int i = 0; i < array.Length; i++)
                    {
                        UnityEngine.Object @object = array[i];
                        if (SpriteAtlasInspector.IsPackable(@object))
                        {
                            DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                            if (current.type == EventType.DragPerform)
                            {
                                this.m_Packables.AppendFoldoutPPtrValue(@object);
                                flag2 = true;
                                DragAndDrop.activeControlID = 0;
                            }
                            else
                            {
                                DragAndDrop.activeControlID = s_LastControlID;
                            }
                        }
                    }
                    if (flag2)
                    {
                        GUI.changed = true;
                        DragAndDrop.AcceptDrag();
                        flag = true;
                    }
                }
                break;

            case EventType.ValidateCommand:
                if (current.commandName == "ObjectSelectorClosed" && ObjectSelector.get.objectSelectorID == SpriteAtlasInspector.s_Styles.packableSelectorHash)
                {
                    flag = true;
                }
                break;

            case EventType.ExecuteCommand:
                if (current.commandName == "ObjectSelectorClosed" && ObjectSelector.get.objectSelectorID == SpriteAtlasInspector.s_Styles.packableSelectorHash)
                {
                    UnityEngine.Object currentObject = ObjectSelector.GetCurrentObject();
                    if (SpriteAtlasInspector.IsPackable(currentObject))
                    {
                        this.m_Packables.AppendFoldoutPPtrValue(currentObject);
                        this.m_PackableList.index = this.m_Packables.arraySize - 1;
                    }
                    flag = true;
                }
                break;

            case EventType.DragExited:
                if (GUI.enabled)
                {
                    HandleUtility.Repaint();
                }
                break;
            }
            this.m_PackableListExpanded = EditorGUI.Foldout(controlRect, this.m_PackableListExpanded, SpriteAtlasInspector.s_Styles.packableListLabel, true);
            if (flag)
            {
                current.Use();
            }
            if (this.m_PackableListExpanded)
            {
                EditorGUI.indentLevel++;
                this.m_PackableList.DoLayoutList();
                EditorGUI.indentLevel--;
            }
        }