private static void ShowList(SerializedProperty list)
        {
            EditorGUILayout.PropertyField(list);
            for (int i = 0; i < list.arraySize; i++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));

                if (GUILayout.Button("Remove"))
                {
                    int oldSize = list.arraySize;
                    list.DeleteArrayElementAtIndex(i);
                    if (list.arraySize == oldSize)
                    {
                        list.DeleteArrayElementAtIndex(i);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add required Skill"))
            {
                list.arraySize += 1;
            }
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        List1 = property.FindPropertyRelative("CharList1");
        #region FORMATTING (IGNORE IT)
        GUI.Box(position, "");
        position.height = SINGLE_LINE_HEIGHT;
        position.y += HALF_BORDER;
        position.x += BUTTON_WIDTH + FULL_BORDER + HALF_BORDER;
        position.width -= BUTTON_WIDTH + FULL_BORDER + FULL_BORDER;
        #endregion

        for (int i = 0; i < List1.arraySize; i++) {
            Rect deleteButton = new Rect(position.x - BUTTON_WIDTH - FULL_BORDER, position.y, BUTTON_WIDTH, position.height);
            if (GUI.Button(deleteButton, _deleteButtonContent)) {
                List1.DeleteArrayElementAtIndex(i); //This is the line that breaks things...
                return;
            }

            EditorGUI.PropertyField(position, List1.GetArrayElementAtIndex(i), new GUIContent(""));
            position.y += position.height + HALF_BORDER;
        }
        #region Add new element (IGNORE)
        position.x -= BUTTON_WIDTH + FULL_BORDER;
        position.width += BUTTON_WIDTH + FULL_BORDER;
        if (GUI.Button(position, "Add new element")) {
            List1.arraySize++;
        }
        #endregion
    }
Example #3
0
        void ShowAnimationList(SerializedProperty animations)
        {
            var count = animations.arraySize;

            // FIXME: should be replaced with DelayedIntField in 5.3
            count = EditorGUILayout.IntField("Animation Count", count);
            count = Mathf.Max(count, 1);

            // enlarge/shrink the list when the size is changed
            while (count > animations.arraySize)
                animations.InsertArrayElementAtIndex(animations.arraySize - 1);
            while (count < animations.arraySize)
                animations.DeleteArrayElementAtIndex(animations.arraySize - 1);

            EditorGUI.indentLevel++;

            for (var i = 0; i < animations.arraySize; i++)
            {
                var data = animations.GetArrayElementAtIndex(i);
                var label_i = new GUIContent("Animation " + i);
                EditorGUILayout.PropertyField(data, label_i);
            }

            EditorGUI.indentLevel--;
        }
Example #4
0
 static void ShowButtons(SerializedProperty list, int index)
 {
     if (GUILayout.Button(moveButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth)) {
         list.MoveArrayElement(index, index + 1);
     }
     if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
         list.InsertArrayElementAtIndex(index);
     }
     if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth)) {
         int oldSize = list.arraySize;
         list.DeleteArrayElementAtIndex(index);
         if (list.arraySize == oldSize) {
             list.DeleteArrayElementAtIndex(index);
         }
     }
 }
Example #5
0
 public void AttackPatternField(SerializedProperty attackPatterns)
 {
     Vector3 moveRemove = new Vector3(-1f, -1f, 0f);
     int c = attackPatterns.FindPropertyRelative ("Array.size").intValue;
     if(c < 1)
     {
         attackPatterns.InsertArrayElementAtIndex(0);
         attackPatterns.GetArrayElementAtIndex(0).objectReferenceValue = gameObject.GetComponent<AbstractAttackPattern>();
     }
     for(int i = 0; i < c; i++)
     {
         EditorGUILayout.BeginHorizontal();
         SerializedProperty arrayElement = attackPatterns.GetArrayElementAtIndex(i);
         AbstractAttackPattern ap = (AbstractAttackPattern)arrayElement.objectReferenceValue;
         EditorGUILayout.PropertyField(arrayElement, new GUIContent((ap != null) ? GetAttackPatternName(ap) : i.ToString()));
         moveRemove = DanmakuEditorUtils.UpDownRemoveButtons(moveRemove, c, i, false);
         EditorGUILayout.EndHorizontal();
     }
     if (moveRemove.y >= 0)
     {
         int removeIndex = (int)moveRemove.y;
         if(attackPatterns.GetArrayElementAtIndex(removeIndex).objectReferenceValue != null)
         {
             attackPatterns.DeleteArrayElementAtIndex(removeIndex);
         }
         attackPatterns.DeleteArrayElementAtIndex(removeIndex);
     }
     if (moveRemove.x >= 0)
     {
         int moveIndex = (int)moveRemove.x;
         if (moveRemove.z > 0)
         {
             attackPatterns.MoveArrayElement (moveIndex, moveIndex + 1);
         }
         if (moveRemove.z < 0)
         {
             attackPatterns.MoveArrayElement (moveIndex, moveIndex - 1);
         }
     }
     if (GUILayout.Button("Add"))
     {
         attackPatterns.InsertArrayElementAtIndex(c);
     }
 }
Example #6
0
        protected void ArrayList(SerializedProperty property, string title, Runnable1<SerializedProperty> renderer)
        {
            if (Foldout(title, false)) {
            Indent(() => {
                if (property.arraySize == 0) {
                    GUILayout.Label("   Use 'Add' button to add items");
                } else {
                    int arrSize = property.arraySize;
                    Separator();
                    for (int i = 0; i < arrSize; ++i) {
                        var go = property.GetArrayElementAtIndex(i);
                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.BeginVertical();
                        renderer(go);
                        EditorGUILayout.EndVertical();

                        GUI.color = Color.red;
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false))) {
                            property.DeleteArrayElementAtIndex(i);
                            arrSize--;
                        }
                        GUI.color = Color.white;
                        EditorGUILayout.EndHorizontal();

                        if (i + 1 < arrSize) {
                            EditorGUILayout.Space();
                        }
                        Separator();
                    }
                }

                GUI.color = Color.green;
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) {
                    property.InsertArrayElementAtIndex(property.arraySize);

                    // when creating new array element like this, the color will be initialized with
                    // (0, 0, 0, 0) - zero aplha. This may be confusing for end user so this workaround looks
                    // for color fields and sets them to proper values
                    var element = property.GetArrayElementAtIndex(property.arraySize - 1);
                    var enumerator = element.GetEnumerator();
                    while (enumerator.MoveNext()) {
                        var el = enumerator.Current as SerializedProperty;
                        if (el.type == "ColorRGBA") {
                            el.colorValue = Color.white;
                        }
                    }
                }
                GUI.color = Color.white;
                EditorGUILayout.EndHorizontal();
            });
            }
        }
 public static void DrawList(ref Rect position, SerializedProperty property)
 {
     position.height = 16;
     EditorGUI.PropertyField (position, property);
     position.y += 18;
     EditorGUI.indentLevel++;
     if (property.isExpanded) {
         Rect buttonPosition;
         for (int i = 0; i < property.arraySize; i++) {
             buttonPosition = position;
             buttonPosition.height = 16;
             buttonPosition.width = 20;
             buttonPosition.x += position.width - 62;
             if (GUI.Button (buttonPosition, moveButtonContent, EditorStyles.miniButtonLeft)) {
                 property.MoveArrayElement (i, i + 1);
             }
             buttonPosition.x += 20;
             if (GUI.Button (buttonPosition, duplicateButtonContent, EditorStyles.miniButtonMid)) {
                 property.InsertArrayElementAtIndex (i);
             }
             buttonPosition.x += 20;
             if (GUI.Button (buttonPosition, deleteButtonContent, EditorStyles.miniButtonRight)) {
                 int oldsize = property.arraySize;
                 property.DeleteArrayElementAtIndex (i);
                 if (oldsize == property.arraySize) {
                     property.DeleteArrayElementAtIndex (i);
                 }
             } else {
                 DrawProperty (ref position, property.GetArrayElementAtIndex (i), true);
             }
         }
         buttonPosition = position;
         buttonPosition.height = 16;
         buttonPosition.width -= EditorGUI.indentLevel * 16;
         buttonPosition.x += EditorGUI.indentLevel * 16;
         if (GUI.Button (buttonPosition, addButtonContent, EditorStyles.miniButton)) {
             property.arraySize += 1;
         }
         position.y += 18;
     }
     EditorGUI.indentLevel--;
 }
        /// <summary>
        /// Draw an element inside the target array property.
        /// </summary>
        /// <param name="arrayProperty">Array property.</param>
        /// <param name="elementIndex">Element index to get the element out of the array property.</param>
        /// <param name="getSelectedIndex">Get selected index.</param>
        /// <param name="setSelectedIndex">Set selected index.</param>
        /// <param name="drawInnerProperties">Action to draw inner properties of the element property.</param>
        void DrawArrayElement(SP arrayProperty, int elementIndex, string minSizeWarning, int minSize,
                              Func <int> getSelectedIndex, Action <int> setSelectedIndex, Action <SP> drawInnerProperties)
        {
            var elementProperty = arrayProperty.GetArrayElementAtIndex(elementIndex);

            EGL.BeginHorizontal();

            EGL.BeginVertical(E_SM.GetCustomStyle("Item Box"));

            if (drawInnerProperties != null)
            {
                drawInnerProperties(elementProperty);
            }

            EGL.EndVertical();

            var deleteIcon           = EditorGUIUtility.IconContent("Toolbar Minus");
            var deleteButtonStyle    = GUIStyle.none;
            var deleteButtonMinWidth = GUILayout.MaxWidth(E_SM.smallButtonWidth);

            /// Draw a button to remove element property from array property.
            bool canDelete = arrayProperty.arraySize > minSize;

            EditorGUI.BeginDisabledGroup(!canDelete); // Disable the "-" button
            if (GUILayout.Button(deleteIcon, deleteButtonStyle, deleteButtonMinWidth))
            {
                if (arrayProperty.arraySize > minSize)
                {
                    if (getSelectedIndex() > elementIndex)
                    {
                        setSelectedIndex(getSelectedIndex() - 1);
                    }

                    arrayProperty.DeleteArrayElementAtIndex(elementIndex);

                    /// We need to return here so the deleted element won't be displayed in the codes below,
                    /// causing unexpected error.
                    return;
                }

                if (!string.IsNullOrEmpty(minSizeWarning))
                {
                    Debug.Log(minSizeWarning);
                }
            }
            EditorGUI.EndDisabledGroup();

            EGL.EndHorizontal();
        }
    private void CreateArrayPropertyField(SerializedProperty arrayObject, string text, string tooltipText)
    {
        if(CreateButton("Add", "Add element to list.") == true)
            arrayObject.arraySize += 1;

        int objectCount = arrayObject.arraySize;
        for(int i = 0; i < objectCount; ++i)
        {
            EditorGUILayout.BeginHorizontal();
            CreatePropertyField(arrayObject.GetArrayElementAtIndex(i), text, tooltipText);
            bool removeButtonIsPressed = CreateButton("Remove", "Removes the current element from the list.");
            EditorGUILayout.EndHorizontal();
            if(removeButtonIsPressed == true)
            {
                arrayObject.DeleteArrayElementAtIndex(i);
                break;
            }
        }
    }
Example #10
0
    private static void ShowButtons(SerializedProperty list, int index)
    {
        if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth))
        {
            list.InsertArrayElementAtIndex(index);
            if (index < list.arraySize - 2)
            {
                Vector3 vector1 = list.GetArrayElementAtIndex(index).vector3Value;
                Vector3 vector2 = list.GetArrayElementAtIndex(index+2).vector3Value;
                Vector3 newVector = (vector2 + vector1)/2;
                newVector.z = vector1.z;
                list.GetArrayElementAtIndex(index + 1).vector3Value = newVector;
            }

        }
        if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth))
        {
            list.DeleteArrayElementAtIndex(index);
        }
    }
Example #11
0
    //删除元素,知识点与上面的添加相似
    public void Remove(string key)
    {
        UnityEditor.SerializedObject   serializedObject = new UnityEditor.SerializedObject(this);
        UnityEditor.SerializedProperty dataProperty     = serializedObject.FindProperty("data");
        int i;

        for (i = 0; i < data.Count; i++)
        {
            if (data[i].key == key)
            {
                break;
            }
        }
        if (i != data.Count)
        {
            dataProperty.DeleteArrayElementAtIndex(i);
        }
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
 //removes rect from the font settings and lists
 void RemoveRect()
 {
     ReFocusBlank = true;
     CharCount -= 1;
     SO = new SerializedObject( FontList[Rects[ClickedRectInd].fontIndex] );
     p = SO.FindProperty( "m_CharacterRects" );
     p.Next( true );
     p.DeleteArrayElementAtIndex( Rects[ClickedRectInd].CIIndex );
     SO.ApplyModifiedProperties(); //remove it from the actual font
     for ( int i = 0; i < Rects.Count; i++ ) { //Shift down all the CIindex for all rects in this font
         if ( Rects[i].fontIndex == Rects[ClickedRectInd].fontIndex && Rects[i].CIIndex > Rects[ClickedRectInd].CIIndex ) {
             Rects[i].CIIndex--;
         }
     }
     Rects.RemoveAt( ClickedRectInd ); //delete from the rect list
     if ( SpriteEditor ) { //check if removing has changed dupes
         CheckSprites();
     } else {
         CheckDupeChars();
     }
     ClickedRectInd--;
     ChrL--;
     if ( Rects.Count > 0 && ClickedRectInd == -1 ) {
         ClickedRectInd = 0;
     }
     if ( Rects.Count > 0 ) {
         GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex );
     } else {
         SpriteIndex = 0;
         SpriteIndexOld = 0;
     }
 }
    //OnGUI
    void OnGUI()
    {
        //qwer
        if ( UsingEditor && Rects == null ) {
            UsingEditor = false;
            UsingMenu = true;
            Debug.Log( Rects );
        }
        #if UNITY_2_6 || UNITY_2_6_1 ||UNITY_3_0 ||UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
        Undo.CreateSnapshot();
        Undo.RegisterSnapshot();
        #else
        //This might not be needed?
        //Undo.RecordObjects( FontList, "Font Changed" );
        #endif
        wantsMouseMove = true;
        MenuBar = new Rect( 0, 0, 150, position.height );
        Event e = Event.current;

        //change gui focus to a blank control
        if ( ReFocusBlank ) {
            GUI.FocusControl( "" );
            ReFocusBlank = false;
        }

        //change gui focus to CharacterEntry
        if ( ReFocusChar ) {
            GUI.FocusControl( "CharacterEntry" );
            ReFocusChar = false;
        }

        //this disbles the editor when playmode is started - a bunch of vars are not preseved, leading to console being flooded with errors. better to just disable it
        if ( !PMS && PM != EditorApplication.isPlaying ) {
            if ( PM ) {
                PM = false;
            } else {
                position = new Rect( position.x, position.y - 5, 220, 150 );
                PMS = true;
                return;
            }
        }

        if ( PMS ) {
            GUI.skin = theGUISkin;
            GUI.BeginGroup( new Rect( position.width / 2 - 80, position.height / 2 - 50, 160, 80 ) );
            GUI.Box( new Rect( 0, 0, 160, 80 ), "" );
            GUI.Label( new Rect( 10, 4, 140, 80 ), "This extension doesn't support entering PlayMode, please close and re-open it's window" );
            GUI.EndGroup();
            return;
        }

        if ( UsingPacker ) {
            drawOffsetPos = Vector2.Lerp( drawOffsetPos, drawOffsetPosDest, 0.02f );
            //Rightmouse down, start drawOffset pan
            if ( e.type == EventType.MouseDown && ( e.button == 2 || e.button == 1 ) ) {
                drawOffsetClick = true;
            }

            //Right Mouseup from drawOffset move
            if ( e.type == EventType.MouseUp && ( e.button == 2 || e.button == 1 ) && drawOffsetClick ) {
                drawOffsetClick = false;
            }

            //Dragging with rightmouse, update drawOffset pan
            if ( e.type == EventType.MouseDrag && ( e.button == 2 || e.button == 1 ) && drawOffsetClick ) {
                drawOffsetPosDest = drawOffsetPosDest + Event.current.delta;
                drawOffsetPosDest = new Vector2( Mathf.Clamp( drawOffsetPosDest.x, -( outTex.width / 2 ), ( outTex.width / 2 ) ),
                                                    Mathf.Clamp( drawOffsetPosDest.y, -( outTex.height / 2 ), ( outTex.height / 2 ) ) );
            }

        }

        MouseOffGUI = new Rect( MenuBar.width, 0, position.width - 300, position.height ).Contains( Event.current.mousePosition );
        if ( UsingEditor ) {
            ShrunkX = ( theTex.width - ( position.width - ( MenuBar.width * 2 ) ) ) / 2;
            ShrunkY = ( theTex.height - position.height ) / 2;
            drawOffsetPos = Vector2.Lerp( drawOffsetPos, drawOffsetPosDest, 0.02f );

            if ( e.type == EventType.ScrollWheel ) {
                drawOffsetPosDest /= drawOffsetScaleDest;
                drawOffsetScaleDest = Mathf.Clamp( Mathf.RoundToInt( ( drawOffsetScale + ( e.delta.y > 0 ? -0.5f : 0.5f ) ) * 2 ) / 2.0f, 0.5f, 10 );
                drawOffsetPosDest *= drawOffsetScaleDest;
            }
            drawOffsetScale = Mathf.Lerp( drawOffsetScale, drawOffsetScaleDest, 0.02f );

            //Leftmouse down
            if ( e.type == EventType.MouseDown && e.button == 0 && MouseOffGUI && !AutoSetDialog && !SpriteSetDialog ) {
                //register undo for any mousedown inside the gui

        #if UNITY_2_6 || UNITY_2_6_1 ||UNITY_3_0 ||UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                Undo.CreateSnapshot();
                Undo.RegisterSnapshot();
        #else
                Undo.RecordObjects( FontList, "Font Changed" );
        #endif

                //checkPos is the position of the mouse with respect to the bitmap
                checkPos = new Vector2( ( e.mousePosition.x - MenuBar.width + ShrunkX ) - drawOffsetPosDest.x + ( ( theTex.width / 2 ) * ( drawOffsetScale - 1 ) ), theTex.height - ( e.mousePosition.y + ShrunkY - drawOffsetPosDest.y ) + ( ( theTex.height / 2 ) * ( drawOffsetScale - 1 ) ) ) / drawOffsetScale;
                bool found = false;
                int foundIndex = -1;
                for ( int i = 0; i < Rects.Count; i++ ) {
                    //Check for sprite center
                    Rect SpriteCenterRect = new Rect( Rects[i].rect.x + Rects[i].spritePivot.x - ( 7.0f / drawOffsetScale ), Rects[i].rect.y + Rects[i].spritePivot.y - ( 7.0f / drawOffsetScale ), ( 16.0f / drawOffsetScale ), ( 16.0f / drawOffsetScale ) );
                    if ( SpriteEditor && SpriteCenterRect.Contains( checkPos ) ) {
                        found = true;
                        MovingRectOffset = checkPos - new Vector2( SpriteCenterRect.x + ( 7.0f / drawOffsetScale ), SpriteCenterRect.y + ( 7.0f / drawOffsetScale ) );
                        MovingSpriteCenter = true;
                        MovingAllSpriteCenterStart = Rects[i].spritePivot;
                        foundIndex = i;
                        break;
                    }

                    //Check for offset slider
                    Rect SliderRect;
                    if ( Rects[i].Orient ) {
                        SliderRect = new Rect( Rects[i].rect.xMax - Rects[i].vOffset - ( SliderSize / drawOffsetScale ), Rects[i].rect.y, ( SliderSize / drawOffsetScale ) * 2, Rects[i].rect.height );
                    } else {
                        SliderRect = new Rect( Rects[i].rect.x, Rects[i].rect.yMax - Rects[i].vOffset - ( SliderSize / drawOffsetScale ), Rects[i].rect.width, ( SliderSize / drawOffsetScale ) * 2 );
                    }
                    if ( !SpriteEditor && PerCharacterOffset && SliderRect.Contains( checkPos ) ) {
                        found = true;
                        MovingRectOffset = checkPos - new Vector2( SliderRect.x, SliderRect.y );
                        MovingSlider = true;
                        MovingAllSliderStart = Rects[i].vOffset;
                        foundIndex = i;
                        break;
                    }

                    //Check for Rects
                    if ( Rects[i].rect.Contains( checkPos ) ) {
                        found = true;
                        Rect ResizerRect = new Rect( Rects[i].rect.xMax - 11.0f / drawOffsetScale, Rects[i].rect.y, 11.0f / drawOffsetScale, 11.0f / drawOffsetScale );
                        if ( ResizerRect.Contains( checkPos ) ) {
                            ResizingRect = true;
                            ResizingRectOffset = checkPos - new Vector2( Rects[i].rect.x + Rects[i].rect.width, Rects[i].rect.y );
                        } else {
                            MovingRect = true;
                            MovingRectOffset = checkPos - new Vector2( Rects[i].rect.x, Rects[i].rect.y );
                        }
                        foundIndex = i;
                        break;
                    }
                }

                if ( found ) {
                    ClickedRectInd = foundIndex;
                    GUI.FocusControl( "" );
                    GetFontInfoToGUI( Rects[foundIndex].CIIndex, ( SpriteEditor ? Rects[foundIndex].fontIndex : 0 ) );
                    ReFocusChar = true;
                    ClickedOnRect = true;
                }
            }

            //Leftmouse HOLD, dragging something
            if ( e.type == EventType.MouseDrag && e.button == 0 ) {
                checkPos = new Vector2( ( e.mousePosition.x - MenuBar.width + ShrunkX ) - drawOffsetPosDest.x + ( ( theTex.width / 2 ) * ( drawOffsetScale - 1 ) ), theTex.height - ( e.mousePosition.y + ShrunkY - drawOffsetPosDest.y ) + ( ( theTex.height / 2 ) * ( drawOffsetScale - 1 ) ) ) / drawOffsetScale;

                if ( MovingSpriteCenter ) {//Moving a sprite center
                    if ( MovingAllToggle ) {
                        switch ( Snap ) {
                            case 0:
                                for ( int i = 0; i < Rects.Count; i++ ) {
                                    if ( MovingAllSpriteToggle && Rects[i].fontIndex != Rects[ClickedRectInd].fontIndex ) { continue; }
                                    Rects[i].spritePivot = Rects[i].spritePivot + new Vector2( ( checkPos.x - MovingRectOffset.x ) - Rects[ClickedRectInd].rect.x, ( checkPos.y - MovingRectOffset.y ) - Rects[ClickedRectInd].rect.y ) - MovingAllSpriteCenterStart;
                                    UpdateFont( i, Rects[i].CIIndex, Rects[i].fontIndex, false );
                                }
                                break;
                            case 1:
                                Rects[ClickedRectInd].spritePivot = new Vector2( ( checkPos.x - MovingRectOffset.x ) - Rects[ClickedRectInd].rect.x, ( checkPos.y - MovingRectOffset.y ) - Rects[ClickedRectInd].rect.y );
                                Rects[ClickedRectInd].spritePivot.x = Mathf.Clamp( Mathf.RoundToInt( Rects[ClickedRectInd].spritePivot.x / ( Rects[ClickedRectInd].rect.width / 2 ) ) * ( Rects[ClickedRectInd].rect.width / 2 ), 0, Rects[ClickedRectInd].rect.width );
                                Rects[ClickedRectInd].spritePivot.y = Mathf.Clamp( Mathf.RoundToInt( Rects[ClickedRectInd].spritePivot.y / ( Rects[ClickedRectInd].rect.height / 2 ) ) * ( Rects[ClickedRectInd].rect.height / 2 ), 0, Rects[ClickedRectInd].rect.height );
                                Vector2 snapVector;
                                snapVector.x = Rects[ClickedRectInd].spritePivot.x / Rects[ClickedRectInd].rect.width;
                                snapVector.y = Rects[ClickedRectInd].spritePivot.y / Rects[ClickedRectInd].rect.height;
                                for ( int i = 0; i < Rects.Count; i++ ) {
                                    if ( MovingAllSpriteToggle && Rects[i].fontIndex != Rects[ClickedRectInd].fontIndex ) { continue; }
                                    if ( i == ClickedRectInd ) { continue; }
                                    Rects[i].spritePivot = new Vector2( snapVector.x * Rects[i].rect.width, snapVector.y * Rects[i].rect.height );
                                    UpdateFont( i, Rects[i].CIIndex, Rects[i].fontIndex, false );
                                }
                                break;
                            case 2:
                                for ( int i = 0; i < Rects.Count; i++ ) {
                                    if ( MovingAllSpriteToggle && Rects[i].fontIndex != Rects[ClickedRectInd].fontIndex ) { continue; }
                                    Rects[i].spritePivot = Rects[i].spritePivot + new Vector2( ( checkPos.x - MovingRectOffset.x ) - Rects[ClickedRectInd].rect.x, Rects[ClickedRectInd].spritePivot.y ) - MovingAllSpriteCenterStart;
                                    Rects[i].spritePivot = RoundedV2( Rects[i].spritePivot );
                                    UpdateFont( i, Rects[i].CIIndex, Rects[i].fontIndex, false );
                                }
                                break;
                            case 3:
                                for ( int i = 0; i < Rects.Count; i++ ) {
                                    if ( MovingAllSpriteToggle && Rects[i].fontIndex != Rects[ClickedRectInd].fontIndex ) { continue; }
                                    Rects[i].spritePivot = Rects[i].spritePivot + new Vector2( Rects[ClickedRectInd].spritePivot.x, ( checkPos.y - MovingRectOffset.y ) - Rects[ClickedRectInd].rect.y ) - MovingAllSpriteCenterStart;
                                    Rects[i].spritePivot = RoundedV2( Rects[i].spritePivot );
                                    UpdateFont( i, Rects[i].CIIndex, Rects[i].fontIndex, false );
                                }
                                break;
                        }
                        MovingAllSpriteCenterStart = Rects[ClickedRectInd].spritePivot;
                    } else {
                        switch ( Snap ) {
                            case 0:
                                Rects[ClickedRectInd].spritePivot = new Vector2( ( checkPos.x - MovingRectOffset.x ) - Rects[ClickedRectInd].rect.x, ( checkPos.y - MovingRectOffset.y ) - Rects[ClickedRectInd].rect.y );
                                break;
                            case 1:
                                Rects[ClickedRectInd].spritePivot = new Vector2( ( checkPos.x - MovingRectOffset.x ) - Rects[ClickedRectInd].rect.x, ( checkPos.y - MovingRectOffset.y ) - Rects[ClickedRectInd].rect.y );
                                Rects[ClickedRectInd].spritePivot.x = Mathf.Clamp( Mathf.RoundToInt( Rects[ClickedRectInd].spritePivot.x / ( Rects[ClickedRectInd].rect.width / 2 ) ) * ( Rects[ClickedRectInd].rect.width / 2 ), 0, Rects[ClickedRectInd].rect.width );
                                Rects[ClickedRectInd].spritePivot.y = Mathf.Clamp( Mathf.RoundToInt( Rects[ClickedRectInd].spritePivot.y / ( Rects[ClickedRectInd].rect.height / 2 ) ) * ( Rects[ClickedRectInd].rect.height / 2 ), 0, Rects[ClickedRectInd].rect.height );
                                break;
                            case 2:
                                Rects[ClickedRectInd].spritePivot = new Vector2( ( checkPos.x - MovingRectOffset.x ) - Rects[ClickedRectInd].rect.x, Rects[ClickedRectInd].spritePivot.y );
                                break;
                            case 3:
                                Rects[ClickedRectInd].spritePivot = new Vector2( Rects[ClickedRectInd].spritePivot.x, ( checkPos.y - MovingRectOffset.y ) - Rects[ClickedRectInd].rect.y );
                                break;
                        }
                        if ( Snap != 1 ) { Rects[ClickedRectInd].spritePivot = RoundedV2( Rects[ClickedRectInd].spritePivot ); }
                        UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex, true );
                    }
                }

                if ( MovingSlider ) { //Moving an offset slider
                    if ( MovingAllToggle ) {
                        for ( int i = 0; i < Rects.Count; i++ ) {
                            if ( Rects[ClickedRectInd].Orient ) {
                                Rects[i].vOffset = Rects[i].vOffset + ( -( checkPos.x - Rects[ClickedRectInd].rect.xMax - MovingRectOffset.x + ( SliderSize / drawOffsetScale ) ) - MovingAllSliderStart );
                            } else {
                                Rects[i].vOffset = Rects[i].vOffset + ( -( checkPos.y - Rects[ClickedRectInd].rect.yMax - MovingRectOffset.y + ( SliderSize / drawOffsetScale ) ) - MovingAllSliderStart );
                            }
                            UpdateFont( i, Rects[i].CIIndex, Rects[i].fontIndex, false );
                        }
                        MovingAllSliderStart = Rects[ClickedRectInd].vOffset;
                    } else {
                        switch ( Snap ) {
                            case 1: // SNAP
                                SnapFound = false;
                                for ( int i = 0; i < Rects.Count; i++ ) {
                                    if ( i == ClickedRectInd ) { continue; }
                                    if ( Rects[i].rect.Contains( checkPos ) ) {//Find a snap, set offset for this rect, to offset of that rect
                                        if ( Rects[ClickedRectInd].Orient ) {
                                            if ( Rects[i].Orient ) { //if Rect a is sideways, is rect b sideways too?
                                                Rects[ClickedRectInd].vOffset = Rects[i].vOffset - Rects[i].rect.xMax + Rects[ClickedRectInd].rect.xMax;
                                            } else {
                                                Rects[ClickedRectInd].vOffset = Rects[i].vOffset;
                                            }
                                        } else {
                                            if ( Rects[i].Orient ) { //if Rect a is upright, is rect b upright too?
                                                Rects[ClickedRectInd].vOffset = Rects[i].vOffset;
                                            } else {
                                                Rects[ClickedRectInd].vOffset = Rects[i].vOffset - Rects[i].rect.yMax + Rects[ClickedRectInd].rect.yMax;
                                            }
                                        }
                                        SnapFound = true;
                                        break;
                                    }
                                }
                                if ( !SnapFound ) {//Couldnt find a snap target, apply non-snap, depending on orient
                                    if ( Rects[ClickedRectInd].Orient ) {
                                        Rects[ClickedRectInd].vOffset = -( checkPos.x - Rects[ClickedRectInd].rect.xMax - MovingRectOffset.x + ( SliderSize / drawOffsetScale ) );
                                    } else {
                                        Rects[ClickedRectInd].vOffset = -( checkPos.y - Rects[ClickedRectInd].rect.yMax - MovingRectOffset.y + ( SliderSize / drawOffsetScale ) );
                                    }
                                }
                                break;
                            default: // Other (no SNAP), depending on orient
                                if ( Rects[ClickedRectInd].Orient ) {
                                    Rects[ClickedRectInd].vOffset = -( checkPos.x - Rects[ClickedRectInd].rect.xMax - MovingRectOffset.x + ( SliderSize / drawOffsetScale ) );
                                } else {
                                    Rects[ClickedRectInd].vOffset = -( checkPos.y - Rects[ClickedRectInd].rect.yMax - MovingRectOffset.y + ( SliderSize / drawOffsetScale ) );
                                }
                                break;
                        }
                        UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex, true );
                    }
                }

                if ( MovingRect || ResizingRect ) { //Moving or resizing a rect
                    Rect OldRect;
                    float OldMaxY = 0, newHeight = 0, newWidth = 0, newY = 0;
                    if ( ResizingRect ) {
                        checkPos -= ResizingRectOffset;
                        OldRect = Rects[ClickedRectInd].rect;
                        OldMaxY = OldRect.y + OldRect.height;
                        newHeight = Mathf.Max( OldMaxY - checkPos.y, 2 );
                        newWidth = Mathf.Max( checkPos.x - OldRect.x, 2 );
                        newY = Mathf.Min( checkPos.y, OldMaxY - 2 );
                    }
                    switch ( Snap ) {
                        case 0: //NO SNAP#
                            if ( MovingRect ) { Rects[ClickedRectInd].rect = new Rect( checkPos.x - MovingRectOffset.x, checkPos.y - MovingRectOffset.y, Rects[ClickedRectInd].rect.width, Rects[ClickedRectInd].rect.height ); }
                            if ( ResizingRect ) { Rects[ClickedRectInd].rect = new Rect( Rects[ClickedRectInd].rect.x, newY, newWidth, newHeight ); }
                            break;
                        case 1: // SNAP
                            if ( MovingRect ) { Rects[ClickedRectInd].rect = SnapToPos( new Rect( checkPos.x - MovingRectOffset.x, checkPos.y - MovingRectOffset.y, Rects[ClickedRectInd].rect.width, Rects[ClickedRectInd].rect.height ), ClickedRectInd ); }
                            if ( ResizingRect ) {
                                if ( !SnapFound ) {
                                    Rects[ClickedRectInd].rect = SnapToSize( new Rect( Rects[ClickedRectInd].rect.x, newY, newWidth, newHeight ), ClickedRectInd );
                                } else if ( !SnapRect.Contains( Event.current.mousePosition ) ) {
                                    SnapFound = false;
                                }
                            }
                            break;
                        case 2: // CONSTRAIN TO X
                            if ( MovingRect ) { Rects[ClickedRectInd].rect = new Rect( checkPos.x - MovingRectOffset.x, Rects[ClickedRectInd].rect.y, Rects[ClickedRectInd].rect.width, Rects[ClickedRectInd].rect.height ); }
                            if ( ResizingRect ) { Rects[ClickedRectInd].rect = new Rect( Rects[ClickedRectInd].rect.x, Rects[ClickedRectInd].rect.y, newWidth, Rects[ClickedRectInd].rect.height ); }
                            break;
                        case 3: // CONSTRAIN TO Y
                            if ( MovingRect ) { Rects[ClickedRectInd].rect = new Rect( Rects[ClickedRectInd].rect.x, checkPos.y - MovingRectOffset.y, Rects[ClickedRectInd].rect.width, Rects[ClickedRectInd].rect.height ); }
                            if ( ResizingRect ) { Rects[ClickedRectInd].rect = new Rect( Rects[ClickedRectInd].rect.x, newY, Rects[ClickedRectInd].rect.width, newHeight ); }
                            break;
                    }
                    Rects[ClickedRectInd].rect = RoundedRect( Rects[ClickedRectInd].rect );
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                }
            }

            //Leftmouse Up, END ANY MOVE OR RESIZE
            if ( e.rawType == EventType.MouseUp && e.button == 0 ) {
                CheckOverlapRects();
                MovingRect = false;
                ResizingRect = false;
                MovingSlider = false;
                MovingSpriteCenter = false;
            }

            //Rightmouse down, start drawOffset pan
            if ( e.type == EventType.MouseDown && ( e.button == 2 || e.button == 1 ) && MouseOffGUI ) {
                drawOffsetClick = true;
            }

            //Right Mouseup from drawOffset move
            if ( e.type == EventType.MouseUp && ( e.button == 2 || e.button == 1 ) && drawOffsetClick ) {
                drawOffsetClick = false;
            }

            //Dragging with rightmouse, update drawOffset pan
            if ( e.type == EventType.MouseDrag && ( e.button == 2 || e.button == 1 ) && drawOffsetClick ) {
                drawOffsetPosDest = drawOffsetPosDest + Event.current.delta;
                drawOffsetPosDest = new Vector2( Mathf.Clamp( drawOffsetPosDest.x, -( theTex.width / 2 ) * drawOffsetScale, ( theTex.width / 2 ) * drawOffsetScale ),
                                                    Mathf.Clamp( drawOffsetPosDest.y, -( theTex.height / 2 ) * drawOffsetScale, ( theTex.height / 2 ) * drawOffsetScale ) );
            }
        }

        //Now GUI drawing, buttons, etc

        PromptOffset1 = Mathf.Lerp( PromptOffset1, PromptOffset1Dest, 0.01f );
        PromptOffset2 = Mathf.Lerp( PromptOffset2, PromptOffset2Dest, 0.01f );
        PromptOffset3 = Mathf.Lerp( PromptOffset3, PromptOffset3Dest, 0.01f );
        PromptOffset4 = Mathf.Lerp( PromptOffset4, PromptOffset4Dest, 0.01f );
        if ( PromptOffset1 < 1 && PromptOffset1Dest == 0 ) { MenuPrompt = false; }
        if ( PromptOffset2 < 1 && PromptOffset2Dest == 0 ) { ResetPrompt = false; }
        if ( PromptOffset3 < 1 && PromptOffset3Dest == 0 ) { AutoPrompt = false; }
        if ( PromptOffset4 < 1 && PromptOffset4Dest == 0 ) { DialogStop = false; }

        GUI.skin = theGUISkin;

        //Draw Main Menu
        if ( UsingMenu ) {
            GUI.Box( MenuBar, "" ); //////Left Box
            GUI.BeginGroup( new Rect( 4, 4, position.width - 4, MenuBar.height - 8 ) );//Clip The Menu pics
            GUI.DrawTexture( new Rect( 0, 0, MenuPics[1].width, MenuPics[1].height ), MenuPics[1] );
            GUI.EndGroup();
            GUI.Box( new Rect( position.width - MenuBar.width, 0, MenuBar.width, MenuBar.height ), "" );/////RightBox
            GUI.BeginGroup( new Rect( 4, 4, position.width - 4, MenuBar.height - 8 ) );//Clip The Menu pics
            GUI.DrawTexture( new Rect( position.width - 8 - MenuPics[2].width, 0, MenuPics[2].width, MenuPics[2].height ), MenuPics[2] );
            GUI.EndGroup();

            GUI.skin = null;
            GUI.BeginGroup( new Rect( position.width - 140, 10, 130, 200 ) ); // Get tex and font for packer
            EditorGUIUtility.LookLikeControls( 65, 40 );
            if ( SpriteEditor ) {
                inFontContainer = (AnimatedSprite) EditorGUI.ObjectField( new Rect( 0, 5, 130, 20 ), "Sprite In", inFontContainer, typeof( AnimatedSprite ), false );
                outFontContainer = (AnimatedSprite) EditorGUI.ObjectField( new Rect( 0, 25, 130, 20 ), "Sprite Out", outFontContainer, typeof( AnimatedSprite ), false );
            } else {
                inFont = (Font) EditorGUI.ObjectField( new Rect( 0, 5, 130, 20 ), "Font In", inFont, typeof( Font ), false );
                outFont = (Font) EditorGUI.ObjectField( new Rect( 0, 25, 130, 20 ), "Font Out", outFont, typeof( Font ), false );
            }
            GUI.skin = theGUISkin;
            GUI.enabled = ( ( !SpriteEditor && inFont != null && outFont != null && inFont != outFont ) ||
             ( SpriteEditor && inFontContainer != null && outFontContainer != null && inFontContainer != outFontContainer ) );
            if ( GUI.Button( new Rect( 0, 55, 130, 30 ), SpriteEditor ? "Start SpritePacker" : "Start FontPacker" ) ) {
                Begin( SpriteEditor ? 3 : 2 );
            }
            GUI.EndGroup();

            GUI.enabled = true;
            GUI.skin = null;
            GUI.BeginGroup( new Rect( 10, 10, 130, 500 ) ); // Get tex and font for setter
            if ( SpriteEditor ) {
                EditorGUIUtility.LookLikeControls( 40, 80 );
                FontContainer = (AnimatedSprite) EditorGUI.ObjectField( new Rect( 0, 5, 130, 20 ), "Sprite", FontContainer, typeof( AnimatedSprite ), false );
            } else {
                EditorGUIUtility.LookLikeControls( 40, 80 );
                theFont = (Font) EditorGUI.ObjectField( new Rect( 0, 5, 130, 20 ), "Font", theFont, typeof( Font ), false );
            }
            GUI.skin = theGUISkin;
            GUI.enabled = ( ( !SpriteEditor && theFont != null ) || ( SpriteEditor && FontContainer != null ) );
            if ( GUI.Button( new Rect( 0, 55, 130, 30 ), SpriteEditor ? "Start SpriteSetter" : "Start FontSetter" ) ) {
                Begin( SpriteEditor ? 1 : 0 );
            }
            GUI.enabled = true;
            UsePreview = GUI.Toggle( new Rect( 0, 90, 130, 20 ), UsePreview, "Preview 3DText" );
            GUI.EndGroup();

            GUI.BeginGroup( new Rect( 4, position.height - 24, 130, 30 ) ); // Switch to SpriteEditor
            SpriteEditor = GUI.Toggle( new Rect( 0, 0, 130, 20 ), SpriteEditor, "Sprite Mode" );
            GUI.EndGroup();

        } //Enf of main menu

        //Draw FontSetter
        if ( UsingEditor ) {
            if ( e.type == EventType.ValidateCommand && e.commandName == "UndoRedoPerformed" ) {
                HarvestRects( 0, true );
            }
            GUI.skin = theGUISkin;
            GUI.Box( MenuBar, "" ); //////Left Box
            GUI.BeginGroup( new Rect( 4, 4, position.width - 4, MenuBar.height - 8 ) );//Clip The Menu pics
            GUI.DrawTexture( new Rect( 0, 0, MenuPics[1].width, MenuPics[1].height ), MenuPics[1] );
            GUI.EndGroup();
            GUI.Box( new Rect( position.width - MenuBar.width, 0, MenuBar.width, MenuBar.height ), "" );/////RightBox
            GUI.BeginGroup( new Rect( 4, 4, position.width - 4, MenuBar.height - 8 ) );//Clip The Menu pics
            GUI.DrawTexture( new Rect( position.width - 8 - MenuPics[0].width, 0, MenuPics[0].width, MenuPics[0].height ), MenuPics[0] );
            GUI.EndGroup();
            GUI.enabled = !AutoSetDialog && !SpriteSetDialog;

            GUI.BeginGroup( new Rect( position.width - 140, 10, 130, 80 ) ); //Undo and shrinkwrap buttons
            if ( GUI.Button( new Rect( 0, 0, 130, 30 ), "Undo" ) ) {
                Undo.PerformUndo();
            }
            GUI.enabled = !AutoSetDialog && !SpriteSetDialog && Rects.Count > 0;
            if ( GUI.Button( new Rect( 10, 40, 110, 25 ), "Shrinkwrap" ) ) {
                ShrinkWrap();
            }
            GUI.EndGroup();
            GUI.enabled = true;
            GUI.BeginGroup( new Rect( MenuBar.width, 0, position.width - 150, position.height ) );//Clip The Background Box
            GUI.color = Color.gray;
            GUI.skin = theGUISkin;
            GUI.Box( new Rect( 0, 0, position.width - 300, position.height ), "", "White" );
            GUI.color = Color.white;
            GUI.EndGroup();

            //Controls in sprite setter
            if ( SpriteEditor && !SpriteSetDialog ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width, 100, MenuBar.width, 200 ) ); //Animation Properties group
                GUI.Box( new Rect( 0, 0, 150, (int) SpritePropertiesLoopBehaviour == 3 ? 160 : ( (int) SpritePropertiesLoopBehaviour == 2 ? 120 : 140 ) ), "" );
                GUI.Label( new Rect( 10, 2, 130, 20 ), "Animation Properties:" );
                EditorGUIUtility.LookLikeControls( 40, 60 );
                SpritePropertiesFontIndex = EditorGUI.Popup( new Rect( 10, 24, 130, 20 ), "Anim:", SpritePropertiesFontIndex, FontListNames );
                SpritePropertiesLoopBehaviour = (SpritePropertiesLoopBehaviourEnum) EditorGUI.EnumPopup( new Rect( 10, 44, 130, 20 ), "Loop:", SpritePropertiesLoopBehaviour );
                if ( (int) SpritePropertiesLoopBehaviour == 3 ) {
                    EditorGUIUtility.LookLikeControls( 70, 60 );
                    SpritePropertiesNextAnim = EditorGUI.Popup( new Rect( 10, 64, 130, 20 ), "Change to:", SpritePropertiesNextAnim, FontListNames );
                }
                if ( (int) SpritePropertiesLoopBehaviour == 0 || (int) SpritePropertiesLoopBehaviour == 1 || (int) SpritePropertiesLoopBehaviour == 3 ) {
                    EditorGUIUtility.LookLikeControls( 105, 60 );
                    SpritePropertiesLoopStart = Mathf.Clamp( EditorGUI.IntField( new Rect( 10, (int) SpritePropertiesLoopBehaviour == 3 ? 84 : 64, 130, 18 ), (int) SpritePropertiesLoopBehaviour == 3 ? "Starting at:" : "Loop start frame:", SpritePropertiesLoopStart ), 0, FontList[(int) SpritePropertiesLoopBehaviour == 3 ? SpritePropertiesNextAnim : SpritePropertiesFontIndex].characterInfo.Length - 2 );
                }
                EditorGUIUtility.LookLikeControls( 105, 60 );
                SpritePropertiesAnimFPS = EditorGUI.FloatField( new Rect( 10, (int) SpritePropertiesLoopBehaviour == 3 ? 102 : ( (int) SpritePropertiesLoopBehaviour == 2 ? 62 : 82 ), 130, 18 ), "Anim FPS Multip:", SpritePropertiesAnimFPS );
                AutoAnimate = GUI.Toggle( new Rect( 10, (int) SpritePropertiesLoopBehaviour == 3 ? 116 : ( (int) SpritePropertiesLoopBehaviour == 2 ? 76 : 96 ), 130, 20 ), AutoAnimate, "Auto-animate" );
                GUI.Label( new Rect( 10, (int) SpritePropertiesLoopBehaviour == 3 ? 134 : ( (int) SpritePropertiesLoopBehaviour == 2 ? 94 : 114 ), 30, 20 ), "" + SpriteFrame );
                SpriteFrame = (int) GUI.HorizontalSlider( new Rect( 28, (int) SpritePropertiesLoopBehaviour == 3 ? 140 : ( (int) SpritePropertiesLoopBehaviour == 2 ? 100 : 120 ), 112, 18 ), SpriteFrame, 0, FontList[SpritePropertiesFontIndex].characterInfo.Length - 2 );

                //if you switch auto on, go back to the start.
                if ( AutoAnimate != AutoAnimateOld ) {
                    AutoAnimateOld = AutoAnimate;
                    if ( AutoAnimate == true ) {
                        SpriteFrame = 0;
                    }
                }

                //choosing a new font needs to update the other fields
                if ( SpritePropertiesFontIndex != SpritePropertiesFontIndexOld ) {
                    ReFocusBlank = true;
                    SpritePropertiesFontIndexOld = SpritePropertiesFontIndex;
                    SpritePropertiesLoopBehaviour = (SpritePropertiesLoopBehaviourEnum) FontList[SpritePropertiesFontIndex].characterInfo[0].index;
                    SpritePropertiesLoopBehaviourOld = SpritePropertiesLoopBehaviour;
                    SpritePropertiesNextAnim = (int) FontList[SpritePropertiesFontIndex].characterInfo[0].uv.x;
                    SpritePropertiesNextAnimOld = SpritePropertiesNextAnim;
                    SpritePropertiesLoopStart = (int) FontList[SpritePropertiesFontIndex].characterInfo[0].uv.y;
                    SpritePropertiesLoopStartOld = SpritePropertiesLoopStart;
                    SpritePropertiesAnimFPS = FontList[SpritePropertiesFontIndex].characterInfo[0].uv.width + 1;
                    SpritePropertiesAnimFPSOld = SpritePropertiesAnimFPS;
                    if ( SpritePreview != null ) {
                        SpritePreviewT.font = FontList[SpritePropertiesFontIndex];
                    }
                    SpriteFrame = 0;
                    ClickedRectInd = FindFrame();
                    if ( ClickedRectInd != -1 ) {
                        GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex );
                    }

                }

                //changing anim properties needs to change the font.CI[0]
                if ( SpritePropertiesLoopBehaviour != SpritePropertiesLoopBehaviourOld ) {
                    SpritePropertiesLoopBehaviourOld = SpritePropertiesLoopBehaviour;
                    SO = new SerializedObject( FontList[SpritePropertiesFontIndex] );
                    p = SO.FindProperty( "m_CharacterRects.Array" );
                    p = p.GetArrayElementAtIndex( 0 );
                    p = p.FindPropertyRelative( "index" );
                    p.intValue = (int) SpritePropertiesLoopBehaviour;
                    SO.ApplyModifiedProperties();
                }

                if ( SpritePropertiesNextAnim != SpritePropertiesNextAnimOld ) {
                    SpritePropertiesNextAnimOld = SpritePropertiesNextAnim;
                    SO = new SerializedObject( FontList[SpritePropertiesFontIndex] );
                    p = SO.FindProperty( "m_CharacterRects.Array" );
                    p = p.GetArrayElementAtIndex( 0 );
                    p = p.FindPropertyRelative( "uv" );
                    p.rectValue = new Rect( SpritePropertiesNextAnim, p.rectValue.y, p.rectValue.width, p.rectValue.height );
                    SO.ApplyModifiedProperties();
                }

                if ( SpritePropertiesLoopStart != SpritePropertiesLoopStartOld ) {
                    SpritePropertiesLoopStartOld = SpritePropertiesLoopStart;
                    SO = new SerializedObject( FontList[SpritePropertiesFontIndex] );
                    p = SO.FindProperty( "m_CharacterRects.Array" );
                    p = p.GetArrayElementAtIndex( 0 );
                    p = p.FindPropertyRelative( "uv" );
                    p.rectValue = new Rect( p.rectValue.x, SpritePropertiesLoopStart, p.rectValue.width, p.rectValue.height );
                    SO.ApplyModifiedProperties();
                }

                if ( SpritePropertiesAnimFPS != SpritePropertiesAnimFPSOld ) {
                    SpritePropertiesAnimFPSOld = SpritePropertiesAnimFPS;
                    SO = new SerializedObject( FontList[SpritePropertiesFontIndex] );
                    p = SO.FindProperty( "m_CharacterRects.Array" );
                    p = p.GetArrayElementAtIndex( 0 );
                    p = p.FindPropertyRelative( "uv" );
                    p.rectValue = new Rect( p.rectValue.x, p.rectValue.y, SpritePropertiesAnimFPS - 1, p.rectValue.height );
                    SO.ApplyModifiedProperties();
                }

                if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Period && MouseOffGUI && !AutoAnimate ) {
                    SpriteFrame++;
                }

                if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Comma && MouseOffGUI && !AutoAnimate ) {
                    SpriteFrame--;
                }

                if ( SpriteFrame != SpriteFrameOld && !AutoAnimate && SpritePreview != null ) {
                    if ( SpriteFrame < 0 ) { SpriteFrame = FontList[SpritePropertiesFontIndex].characterInfo.Length - 2; }
                    if ( SpriteFrame > FontList[SpritePropertiesFontIndex].characterInfo.Length - 2 ) { SpriteFrame = 0; }
                    SpriteFrameOld = SpriteFrame;
                    char C = (char) ( SpriteFrame + 33 );
                    SpritePreviewT.text = "" + C;
                    ClickedRectInd = FindFrame();
                    if ( ClickedRectInd != -1 ) {
                        GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex );
                    }
                }
                GUI.EndGroup();

            }

            GUI.enabled = ( !AutoSetDialog && !SpriteSetDialog && !AutoPrompt && !MenuPrompt );
            GUI.BeginGroup( new Rect( position.width - MenuBar.width + 10, position.height - 150 - PromptOffset1, MenuBar.width - 10, 150 ) ); //RESET Group
            GUI.BeginGroup( new Rect( 0, 30 - PromptOffset2, 130, 30 ) ); //RESET Group
            if ( ResetPrompt ) {
                if ( GUI.Button( new Rect( 0, 0, 60, 30 ), "Reset" ) ) {
                    ResetFont( -1 );
                    PromptOffset2Dest = 0;
                    ResetPrompt = false;
                }
                if ( GUI.Button( new Rect( 70, 0, 60, 30 ), "Cancel" ) ) {
                    PromptOffset2Dest = 0;
                }
            }
            GUI.EndGroup();
            if ( GUI.Button( new Rect( 0, 31, 130, 30 ), "Reset Font" ) ) {
                PromptOffset2Dest = 30;
                PromptOffset1Dest = 0;
                MenuPrompt = false;
                AutoPrompt = false;
                ResetPrompt = true;
            }
            GUI.EndGroup();

            GUI.enabled = ( !AutoSetDialog && !SpriteSetDialog && !ResetPrompt && !MenuPrompt );
            GUI.BeginGroup( new Rect( position.width - MenuBar.width + 10, position.height - 230 - PromptOffset1 - PromptOffset2, MenuBar.width - 10, 200 ) ); //AUTO Group
            GUI.BeginGroup( new Rect( 0, 71 - PromptOffset3, 130, PromptOffset3 ) ); //AUTO Group
            if ( AutoPrompt ) {
                if ( !SpriteEditor ) {
                    if ( GUI.Button( new Rect( 0, 45, 60, 25 ), "Basic" ) ) {
                        ResetFont( -1 );
                        AutoSet();
                        AutoPrompt = false;
                    }
                    if ( GUI.Button( new Rect( 0, 10, 60, 25 ), "Smart" ) ) {
                        SmartMode = true;
                        ResetFont( -1 );
                        AutoSet();
                        AutoPrompt = false;
                    }
                } else {
                    if ( GUI.Button( new Rect( 0, 0, 60, 28 ), "Auto!" ) ) {
                        ResetFont( -1 );
                        AutoSet();
                        AutoPrompt = false;
                    }

                    if ( GUI.Button( new Rect( 0, 29, 60, 20 ), "Get Piv" ) ) {
                        LocatePivots();
                        if ( ClickedRectInd != -1 ) { GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex ); }
                        PromptOffset3Dest = 0;
                    }

                    if ( GUI.Button( new Rect( 0, 50, 60, 20 ), "Draw Piv" ) ) {
                        DrawSpritePivots();
                    }
                }

                GUI.Label( new Rect( 63, 0, 150, 20 ), SpriteEditor ? "Pivot Color:" : "SmartColor:" );
                SmartColor = EditorGUI.ColorField( new Rect( 71, 20, 60, 20 ), SmartColor );

                if ( GUI.Button( new Rect( 70, 45, 60, 25 ), "Cancel" ) ) {
                    PromptOffset3Dest = 0;
                }
            }
            GUI.EndGroup();
            if ( GUI.Button( new Rect( 0, 71, 130, 30 ), "Auto Set" ) ) {
                PromptOffset1Dest = 0;
                PromptOffset2Dest = 0;
                PromptOffset3Dest = 71;
                AutoPrompt = true;
                ResetPrompt = false;
                MenuPrompt = false;
            }
            GUI.EndGroup();
            GUI.enabled = true;

            GUI.BeginGroup( new Rect( position.width - MenuBar.width + 10, position.height - 80 - PromptOffset1, MenuBar.width, 150 ) ); //ResetCam Group
            if ( GUI.Button( new Rect( 0, 0, 130, 30 ), "Reset View" ) ) {
                drawOffsetPosDest = Vector2.zero;
                drawOffsetScaleDest = 1;
            }
            GUI.EndGroup();

            GUI.enabled = ( !AutoSetDialog && !SpriteSetDialog && !ResetPrompt && !AutoPrompt );
            GUI.BeginGroup( new Rect( position.width - MenuBar.width + 10, position.height - 70, MenuBar.width, 150 ) ); //Back to menu Group
            GUI.BeginGroup( new Rect( 0, 30 - PromptOffset1, 130, 150 ) ); //Back to menu Group
            if ( MenuPrompt ) {
                if ( GUI.Button( new Rect( 0, 0, 60, 30 ), "Return" ) ) {
                    UsingEditor = false;
                    UsingMenu = true;
                    ResetError();
                    MenuPrompt = false;
                    PromptOffset1Dest = 0;
                    position = new Rect( position.x, position.y - 5, 512, 512 );
                }
                if ( GUI.Button( new Rect( 70, 0, 60, 30 ), "Cancel" ) ) {
                    PromptOffset1Dest = 0;
                }
            }
            GUI.EndGroup();
            if ( GUI.Button( new Rect( 0, 31, 130, 30 ), "Return to Menu" ) ) {
                PromptOffset1Dest = 30;
                PromptOffset2Dest = 0;
                MenuPrompt = true;
                AutoPrompt = false;
                ResetPrompt = false;
            }
            GUI.EndGroup();

            GUI.skin = theGUISkin;
            GUI.enabled = !AutoSetDialog && !SpriteSetDialog;
            GUI.BeginGroup( new Rect( MenuBar.width, 0, ( position.width - 300 ), position.height ) ); //clip the Tex
            GUI.color = BGCol; //Draw a box for the background.
            GUI.Box( new Rect( drawOffsetPos.x - ShrunkX - ( theTex.width / 2 * ( drawOffsetScale - 1 ) ) - 6, drawOffsetPos.y - ShrunkY - ( theTex.height / 2 * ( drawOffsetScale - 1 ) ) - 6, 12 + theTex.width * drawOffsetScale, 12 + theTex.height * drawOffsetScale ), "", "theTexBG" );
            GUI.color = Color.white;//Draw the fonts texture
            GUI.DrawTexture( new Rect( drawOffsetPos.x - ShrunkX - ( theTex.width / 2 * ( drawOffsetScale - 1 ) ), drawOffsetPos.y - ShrunkY - ( theTex.height / 2 * ( drawOffsetScale - 1 ) ), theTex.width * drawOffsetScale, theTex.height * drawOffsetScale ), theTex );
            GUI.EndGroup();

            GUI.BeginGroup( new Rect( MenuBar.width, 0, position.width - 300, position.height ) );//Clip The Rects
            for ( int i = 0; i < Rects.Count; i++ ) {
                if ( RectOnScreen( ConvertPixelsToScreen( Rects[i].rect ) ) ) {
                    Rect ScreenRect = ConvertPixelsToScreen( Rects[i].rect );
                    GUI.Box( ScreenRect, "", i == ClickedRectInd ? "EmptyBoxSelected" : "EmptyBox" ); //draw a rect for each character
                    if ( PerCharacterOffset ) {
                        Rect SliderBox;
                        if ( Rects[i].Orient ) {
                            SliderBox = new Rect( Rects[i].rect.xMax - Rects[i].vOffset - ( SliderSize / drawOffsetScale ), Rects[i].rect.y, ( SliderSize / drawOffsetScale ) * 2, Rects[i].rect.height );
                        } else {
                            SliderBox = new Rect( Rects[i].rect.x, Rects[i].rect.yMax - Rects[i].vOffset - ( SliderSize / drawOffsetScale ), Rects[i].rect.width, ( SliderSize / drawOffsetScale ) * 2 );
                        }
                        GUI.Box( ConvertPixelsToScreen( SliderBox ), "", "GuideLine" ); //draw the slider for each rect
                    }
                    if ( SpriteEditor ) {
                        //draw the sprite pivot, and 2 labels for the sprite index
                        GUI.Box( ConvertPixelsToScreen( new Rect( Rects[i].rect.x + Rects[i].spritePivot.x - ( 7.0f / drawOffsetScale ), Rects[i].rect.y + Rects[i].spritePivot.y - ( 7.0f / drawOffsetScale ), 16.0f / drawOffsetScale, 16.0f / drawOffsetScale ) ), "", i == ClickedRectInd ? "SpritePivotSelected" : "SpritePivot" );
                        GUI.Label( new Rect( ScreenRect.x + 1, ScreenRect.y + 1, ScreenRect.width, ScreenRect.height ), "" + ( FontList[Rects[i].fontIndex].characterInfo[Rects[i].CIIndex].index - 33 ), "RectLabel2" );
                        GUI.color = Colors[Rects[i].fontIndex % Colors.Length];
                        GUI.Label( ScreenRect, "" + ( FontList[Rects[i].fontIndex].characterInfo[Rects[i].CIIndex].index - 33 ), "RectLabel" );
                        GUI.color = Color.white;
                    } else {
                        //draw 2 labels for the character
                        GUI.Label( new Rect( ScreenRect.x + 1, ScreenRect.y + 1, ScreenRect.width, ScreenRect.height ), "" + (char) ( FontList[0].characterInfo[Rects[i].CIIndex].index ), "RectLabel2" );
                        GUI.Label( ScreenRect, "" + (char) FontList[0].characterInfo[Rects[i].CIIndex].index, "RectLabel" );
                    }
                }
            }
            GUI.EndGroup();

            if ( AutoSetDialog || SpriteSetDialog ) {
                GUI.BeginGroup( new Rect( MenuBar.width, 0, position.width - 300, position.height ) );//Clip The Auto Rects
                GUI.enabled = true;
                GUI.Box( ConvertPixelsToScreen( AutoRectList[AutoSetIndex].rect ), "", "AutoBox" );
                GUI.EndGroup();
            }

            GUI.BeginGroup( new Rect( 10, 6, MenuBar.width - 10, 65 ) ); //Size Group
            GUI.Label( new Rect( 0, 0, 140, 40 ), SpriteEditor ? "Number of \nsprites:" : "Number of\ncharacters:" );
            GUI.enabled = false;
            CharCount = EditorGUI.IntField( new Rect( 80, 9, 40, 20 ), CharCount, "TextField" );
            GUI.enabled = !AutoSetDialog && !SpriteSetDialog;

            if ( GUI.Button( new Rect( 0, 42, 50, 20 ), "+1" ) ) {
        #if UNITY_2_6 || UNITY_2_6_1 ||UNITY_3_0 ||UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                Undo.CreateSnapshot();
                Undo.RegisterSnapshot();
        #else
                Undo.RecordObjects( FontList, "Font Changed" );
        #endif
                GUI.FocusControl( "" );
                SO = new SerializedObject( FontList[RectFontIndex] );
                p = SO.FindProperty( "m_CharacterRects.Array.size" );
                WidBefore = 0;
                WidBeforeOld = 0;
                WidAfter = 0;
                WidAfterOld = 0;
                Orient = 0;
                OrientOld = 0;
                SpriteIndex++;
                SpriteIndexOld = SpriteIndex;
                CharCount = CharCount + 1;
                p.intValue++;
                SO.ApplyModifiedProperties();
                SetRect newSetRect = new SetRect();
                if ( ClickedRectInd == -1 ) {
                    newSetRect.rect = new Rect( 0, 0, 100, 100 );
                } else {
                    newSetRect = new SetRect( Rects[ClickedRectInd] );
                }
                newSetRect.CIIndex = FontList[newSetRect.fontIndex].characterInfo.Length - 1;
                Rects.Add( newSetRect );
                ClickedRectInd = CharCount - 1;
                ClickedOnRect = true;
                char newChar = (char) ( ChrL + 1 );
                ChrStr = "" + newChar;
                ChrL++;
                UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                if ( SpriteEditor ) {
                    CheckSprites();
                } else {
                    CheckDupeChars();
                }
                if ( Rects.Count == 1 ) { CameraOnRect( Rects[Rects.Count - 1].rect ); }
            }
            GUI.enabled = ClickedOnRect && !AutoSetDialog && !SpriteSetDialog && ClickedRectInd > -1;

            if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Delete && ClickedRectInd != -1 && MouseOffGUI ) {
                RemoveRect();
            }

            if ( GUI.Button( new Rect( 60, 42, 70, 20 ), "Remove" ) ) {
        #if UNITY_2_6 || UNITY_2_6_1 ||UNITY_3_0 ||UNITY_3_0_0 || UNITY_3_1 || UNITY_3_2 || UNITY_3_3 || UNITY_3_4 || UNITY_3_5 || UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2
                Undo.CreateSnapshot();
                Undo.RegisterSnapshot();
        #else
                Undo.RecordObjects( FontList, "Font Changed" );
        #endif
                RemoveRect();
            }

            GUI.EndGroup(); // End Size Set group

            GUI.BeginGroup( new Rect( 0, 80, MenuBar.width, 200 ) ); //Rect properties group
            GUI.Box( new Rect( 0, 0, 150, SpriteEditor ? 192 : 142 ), "" );
            GUI.Label( new Rect( 10, 2, 140, 20 ), SpriteEditor ? "Sprite Properties:" : "Character Properties:" );
            GUI.Label( new Rect( 33, 23, 140, 20 ), SpriteEditor ? "" : "Character:" );
            GUI.SetNextControlName( "CharacterEntry" );
            if ( SpriteEditor ) {
                EditorGUIUtility.LookLikeControls( 83, 25 );
                SpriteIndex = Mathf.Max( EditorGUI.IntField( new Rect( 15, 23, 128, 20 ), "Sprite Index:", SpriteIndex, "TextField" ), 0 );
                if ( ClickedRectInd > -1 && ( SpriteIndex != SpriteIndexOld ) && !AutoSetDialog && !SpriteSetDialog ) {
                    SpriteIndexOld = SpriteIndex;
                    ChrL = SpriteIndex + 33;
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                    CheckSprites();
                }
            } else {
                ChrStr = EditorGUI.TextField( new Rect( 98, 23, 45, 20 ), "", ChrStr, "TextField" );
                if ( ChrStr.Length != 0 && ChrL != ChrStr[0] && !AutoSetDialog && !SpriteSetDialog && ClickedRectInd != -1 ) {
                    ChrL = ChrStr[0];
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                    CheckDupeChars();
                }
            }

            EditorGUIUtility.LookLikeControls( 20, 25 );
            UVx = EditorGUI.IntField( new Rect( 10, 50, 65, 20 ), "X:", UVx, "TextField" );
            UVy = EditorGUI.IntField( new Rect( 78, 50, 65, 20 ), "Y:", UVy, "TextField" );
            UVw = EditorGUI.IntField( new Rect( 10, 70, 65, 20 ), "W:", UVw, "TextField" );
            UVh = EditorGUI.IntField( new Rect( 78, 70, 65, 20 ), "H:", UVh, "TextField" );

            if ( UVRect != new Rect( UVx, UVy, UVw, UVh ) && !AutoSetDialog && !SpriteSetDialog ) {
                UVRect = new Rect( UVx, UVy, UVw, UVh );
                Rects[ClickedRectInd].rect = UVRect;
                UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
            }

            if ( SpriteEditor ) {
                GUI.Label( new Rect( 12, 95, 100, 60 ), "Sprite Pivot:" );
                EditorGUIUtility.LookLikeControls( 20, 25 );
                Cx = EditorGUI.FloatField( new Rect( 10, 115, 65, 20 ), "X:", Cx, "TextField" );
                Cy = EditorGUI.FloatField( new Rect( 78, 115, 65, 20 ), "Y:", Cy, "TextField" );

                if ( CPos != new Vector2( Cx, Cy ) && !AutoSetDialog && !SpriteSetDialog ) {
                    CPos = new Vector2( Cx, Cy );
                    Rects[ClickedRectInd].spritePivot = CPos;
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                }

                EditorGUIUtility.LookLikeControls( 40, 60 );
                RectFontIndex = EditorGUI.Popup( new Rect( 10, 145, 130, 20 ), "Font:", RectFontIndex, FontListNames );

                //change the font index outside of autoset
                if ( RectFontIndex != RectFontIndexOld && !AutoSetDialog && !SpriteSetDialog && Rects.Count > 1 ) {
                    CharacterInfo CI = FontList[RectFontIndexOld].characterInfo[Rects[ClickedRectInd].CIIndex];
                    SO = new SerializedObject( FontList[RectFontIndexOld] );
                    p = SO.FindProperty( "m_CharacterRects.Array" );
                    p.DeleteArrayElementAtIndex( Rects[ClickedRectInd].CIIndex ); //Delete the CI from the old font
                    SO.ApplyModifiedProperties();
                    for ( int i = 0; i < Rects.Count; i++ ) { //Shift down all the CIindex for all rects in this font
                        if ( Rects[i].fontIndex == RectFontIndexOld && Rects[i].CIIndex > Rects[ClickedRectInd].CIIndex ) {
                            Rects[i].CIIndex--;
                        }
                    }
                    SO = new SerializedObject( FontList[RectFontIndex] );
                    p = SO.FindProperty( "m_CharacterRects.Array.size" );
                    p.intValue = FontList[RectFontIndex].characterInfo.Length + 1; //Expand the new font to accomodate the CI
                    p = SO.FindProperty( "m_CharacterRects.Array" );
                    p2 = p.GetArrayElementAtIndex( FontList[RectFontIndex].characterInfo.Length ); //Set all the values from the CI
                    p2.Next( true ); //p2 is now CharIndex
                    p2.intValue = CI.index;
                    p2.Next( false ); //p2 is now UV Rect
                    p2.rectValue = CI.uv;
                    p2.Next( false ); //p2 is now Vert Rect
                    p2.rectValue = CI.vert;
                    p2.Next( false ); //p2 is now Width
                    p2.floatValue = CI.width;
                    p2.Next( false ); //p2 is now Flip bool
                    p2.boolValue = CI.flipped;
                    SO.ApplyModifiedProperties();

                    Rects[ClickedRectInd].fontIndex = RectFontIndex;
                    Rects[ClickedRectInd].CIIndex = FontList[RectFontIndex].characterInfo.Length - 1;
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                    RectFontIndexOld = RectFontIndex;
                    CheckSprites();
                }

                //change the font index during autoset
                if ( RectFontIndex != RectFontIndexOld && !AutoSetDialog && SpriteSetDialog ) {
                    SpriteIndex = FontList[RectFontIndex].characterInfo.Length - 1;
                    RectFontIndexOld = RectFontIndex;
                }

                GUI.enabled = ErrorMsg[(int) Errors.DupeSprite] || ErrorMsg[(int) Errors.SkipSprite];
                if ( GUI.Button( new Rect( 50, 165, 90, 18 ), "Fix Indices" ) ) {
                    int missing = CheckSprites( Rects[ClickedRectInd].fontIndex );
                    while ( missing != -1 ) {
                        for ( int i = 0; i < Rects.Count; i++ ) {
                            if ( Rects[i].fontIndex == Rects[ClickedRectInd].fontIndex ) {
                                if (
                                ( ErrorMsg[(int) Errors.DupeSprite] && missing != i && FontList[Rects[ClickedRectInd].fontIndex].characterInfo[Rects[i].CIIndex].index >= FontList[Rects[ClickedRectInd].fontIndex].characterInfo[Rects[missing].CIIndex].index ) ||
                                ( ErrorMsg[(int) Errors.SkipSprite] && FontList[Rects[ClickedRectInd].fontIndex].characterInfo[Rects[i].CIIndex].index - 33 > missing ) ) {
                                    SO = new SerializedObject( FontList[Rects[ClickedRectInd].fontIndex] );
                                    p = SO.FindProperty( "m_CharacterRects.Array" );
                                    p2 = p.GetArrayElementAtIndex( Rects[i].CIIndex );
                                    p2.Next( true ); //p2 is now CharIndex
                                    p2.intValue += DupeMissOffset;
                                    SO.ApplyModifiedProperties();
                                }
                            }
                        }
                        missing = CheckSprites( Rects[ClickedRectInd].fontIndex );
                    }
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex );
                }
            } else {
                EditorGUIUtility.LookLikeControls( 88, 25 );
                WidBefore = EditorGUI.FloatField( new Rect( 10, 95, 133, 20 ), "Leading Width:", WidBefore, "TextField" );
                WidAfter = EditorGUI.FloatField( new Rect( 10, 115, 133, 20 ), "Trailing Width:", WidAfter, "TextField" );

                if ( WidBefore != WidBeforeOld && !AutoSetDialog && !SpriteSetDialog ) {
                    WidBeforeOld = WidBefore;
                    Rects[ClickedRectInd].bWidth = WidBefore;
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                }

                if ( WidAfter != WidAfterOld && !AutoSetDialog && !SpriteSetDialog ) {
                    WidAfterOld = WidAfter;
                    Rects[ClickedRectInd].aWidth = WidAfter;
                    UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
                }
            }
            GUI.EndGroup(); // End Rect properties group

            if ( !SpriteEditor ) {
                GUI.enabled = !PerCharacterOffset && !AutoSetDialog;
                if ( GUI.Button( new Rect( 10, 230, 130, 35 ), "Use Per-Character\nVertical Offsets" ) ) {
                    for ( int i = 0; i < Rects.Count; i++ ) {
                        SO = new SerializedObject( FontList[0] );
                        p = SO.FindProperty( "m_CharacterRects" );
                        p.Next( true );
                        p2 = p.GetArrayElementAtIndex( i );
                        p2.Next( true ); //p2 is now CharIndex
                        p2.Next( false ); //p2 is now UV Rect
                        p2.Next( false ); //p2 is now Vert Rect
                        Rects[i].vOffset = p2.rectValue.y;
                    }
                    PerCharacterOffset = true;
                }
            }

            GUI.BeginGroup( new Rect( 10, 270, MenuBar.width - 10, 150 ) ); //Snaps Group
            GUI.Label( new Rect( 0, 0, 100, 20 ), "Snap:" );
            GUI.enabled = ClickedOnRect && !AutoSetDialog && !SpriteSetDialog && ClickedRectInd > -1;
            Snap = GUI.SelectionGrid( new Rect( 0, 20, 130, 40 ), Snap, Snaps, 2 );
            GUI.EndGroup();

            GUI.BeginGroup( new Rect( 0, 330, 150, 250 ) ); //Orientation buttons
            GUI.Label( new Rect( 10, 0, 130, 20 ), "Character Orientation:" );
            Orient = GUI.SelectionGrid( new Rect( 11, 20, 128, 64 ), Orient, OrientPics, 2, "BlankButton" );

            if ( Orient != OrientOld && !AutoSetDialog && !SpriteSetDialog ) {
                OrientOld = Orient;
                Rects[ClickedRectInd].Orient = ( Orient == 1 );
                UpdateFont( ClickedRectInd, Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ), true );
            }
            GUI.EndGroup();

            GUI.BeginGroup( new Rect( 0, 417, 150, 250 ) ); //interface toggles
            GUI.Label( new Rect( 30, 0, 130, 40 ), SpriteEditor ? "Move all\nsprite pivots" : "Move all\nvertical offsets" );
            MovingAllToggle = GUI.Toggle( new Rect( 10, 6, 130, 20 ), MovingAllToggle, "" );
            if ( MovingAllToggle && SpriteEditor ) {
                MovingAllSpriteToggle = GUI.Toggle( new Rect( 10, 32, 130, 20 ), MovingAllSpriteToggle, "Only this anim" );
            }
            GUI.EndGroup();

            GUI.enabled = true;

            GUI.BeginGroup( new Rect( 0, position.height - 40, MenuBar.width, 50 ) ); //BGCol Group
            GUI.Label( new Rect( 10, 0, 130, 40 ), "Background\ncolor:" );
            BGCol = EditorGUI.ColorField( new Rect( 90, 8, 50, 20 ), BGCol );
            GUI.EndGroup();

            if ( AutoSetDialog ) {//AutoSet Dialog
                GUI.BeginGroup( new Rect( position.width - 150, ( position.height / 2 ) - 120, 150, 200 ) ); //Clip AUTOSET Dialog
                GUI.Box( new Rect( 0, 0, 150, 135 + PromptOffset4 ), "" );
                GUI.Label( new Rect( 10, 10, 140, 20 ), "What character is this?" );
                if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Return && AutoSetCharStr.Length > 0 && GUI.GetNameOfFocusedControl() == "AutoText" ) {
                    AddRect( false, 0 );
                }
                if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Escape && GUI.GetNameOfFocusedControl() == "AutoText" ) {
                    SkipRect();
                }
                GUI.SetNextControlName( "AutoText" );
                AutoSetCharStr = EditorGUI.TextField( new Rect( 55, 30, 40, 21 ), "", AutoSetCharStr, "TextField" );
                GUI.enabled = AutoSetCharStr.Length > 0;
                if ( GUI.Button( new Rect( 10, 55, 60, 30 ), "Next" ) ) {
                    AddRect( false, 0 );
                }
                GUI.enabled = true;
                if ( GUI.Button( new Rect( 80, 55, 60, 30 ), "Skip" ) ) {
                    SkipRect();
                }
                GUI.BeginGroup( new Rect( 10, 90 + PromptOffset4, 130, 30 ) ); //stop AUTOSET Dialog
                if ( DialogStop ) {
                    if ( GUI.Button( new Rect( 0, 0, 60, 30 ), "Stop" ) ) {
                        PromptOffset4Dest = 0;
                        EndAutoSet();
                        AutoRectList.Clear();
                    }
                    if ( GUI.Button( new Rect( 70, 0, 60, 30 ), "Cancel" ) ) {
                        PromptOffset4Dest = 0;
                    }
                }
                GUI.EndGroup();
                if ( GUI.Button( new Rect( 10, 90, 130, 30 ), "Stop Auto Set" ) ) {
                    DialogStop = true;
                    PromptOffset4Dest = 30;
                }
                if ( CharRepeatList.Count > 1 && AutoSetIndex == 0 ) {
                    if ( GUI.Button( new Rect( 30, 135 + PromptOffset4, 90, 20 ), "Repeat Last" ) ) {
                        RepeatSetting = true;
                        for ( int i = 0; i < CharRepeatList.Count; i++ ) {
                            if ( CharRepeatList[i] == 0 ) {
                                AutoRectList.RemoveAt( AutoSetIndex );
                                AutoSetCharStr = "";
                            } else {
                                AutoSetCharStr = "" + CharRepeatList[i];
                                AddRect( false, 0 );
                            }
                        }
                        RepeatSetting = false;
                        EndAutoSet();
                    }
                }
                GUI.FocusControl( "AutoText" );
                GUI.EndGroup();
            }

            if ( ErrorMsg[(int) Errors.Spacebar] ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width, 100, MenuBar.width, 200 ) );//SPACEBAR Prompt
                GUI.Box( new Rect( 0, 0, 150, 61 ), "" );
                GUI.Label( new Rect( 10, 4, 135, 60 ), "Don't forget to add a Rect for the Spacebar character!" );
                if ( GUI.Button( new Rect( 96, 39, 50, 18 ), "OK" ) ) {
                    ErrorMsg[(int) Errors.Spacebar] = false;
                }
                GUI.EndGroup();
            }

            if ( ErrorMsg[(int) Errors.SkipSprite] ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width - ( ErrorMsg[(int) Errors.OverlapSprite] ? 323 : 169 ), position.height - 43, 170, 43 ) );//Skipped Sprite
                GUI.Box( new Rect( 0, 0, 170, 43 ), "" );
                SplitError = SkipErrorString.Split( '#' );
                GUI.color = Colors[int.Parse( SplitError[0] )];
                GUI.Label( new Rect( 6, 5, 160, 60 ), SplitError[1], "RectLabel" );
                GUI.color = Color.white;
                GUI.Label( new Rect( 10, 19, 160, 60 ), SplitError[2] );
                GUI.EndGroup();
            }

            if ( ErrorMsg[(int) Errors.DupeSprite] ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width - ( ErrorMsg[(int) Errors.OverlapSprite] ? 308 : 154 ), position.height - 57, 170, 57 ) );//Duped Sprite
                GUI.Box( new Rect( 0, 0, 155, 57 ), "" );
                SplitError = DupeErrorString.Split( '#' );
                GUI.Label( new Rect( 10, 4, 150, 60 ), "" + SplitError[0] );
                GUI.color = Colors[int.Parse( SplitError[1] )];
                GUI.Label( new Rect( 8, 22, 150, 60 ), "" + SplitError[2], "RectLabel" );
                GUI.color = Color.white;
                GUI.Label( new Rect( 10, 34, 150, 60 ), "" + SplitError[3] );
                GUI.EndGroup();
            }

            if ( ErrorMsg[(int) Errors.OverlapSprite] ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width - 154, position.height - 80, 170, 80 ) );//Overlapping Sprite
                GUI.Box( new Rect( 0, 0, 155, 80 ), "" );
                SplitError = OverlapErrorString.Split( '#' );
                GUI.Label( new Rect( 10, 3, 150, 30 ), "The Rect for" );
                GUI.color = Colors[int.Parse( SplitError[0] )];

                if ( GUI.Button( new Rect( 4, 22, 147, 18 ), SplitError[1] ) ) {
                    ClickedRectInd = SecondOverlapRect;
                    ReFocusBlank = true;
                    CameraOnRect( Rects[ClickedRectInd].rect );
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ) );
                }

                GUI.color = Color.white;
                GUI.Label( new Rect( 10, 39, 150, 30 ), "overlaps with" );
                GUI.color = Colors[int.Parse( SplitError[2] )];

                if ( GUI.Button( new Rect( 4, 58, 147, 18 ), SplitError[3] ) ) {
                    ClickedRectInd = FirstOverlapRect;
                    ReFocusBlank = true;
                    CameraOnRect( Rects[ClickedRectInd].rect );
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ) );
                }

                GUI.color = Color.white;
                GUI.EndGroup();
            }

            if ( ErrorMsg[(int) Errors.DupeChar] ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width - 129, position.height - 60, 130, 60 ) );//Duped Character
                GUI.Box( new Rect( 0, 0, 130, 60 ), "" );
                GUI.Label( new Rect( 8, 2, 120, 60 ), DupeErrorString );
                if ( GUI.Button( new Rect( 4, 38, 60, 18 ), "First" ) ) {
                    ClickedRectInd = FirstDupeRect;
                    ReFocusBlank = true;
                    CameraOnRect( Rects[ClickedRectInd].rect );
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ) );
                }
                if ( GUI.Button( new Rect( 66, 38, 60, 18 ), "Second" ) ) {
                    ClickedRectInd = SecondDupeRect;
                    ReFocusBlank = true;
                    CameraOnRect( Rects[ClickedRectInd].rect );
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ) );
                }
                GUI.EndGroup();
            }

            if ( ErrorMsg[(int) Errors.OverlapChar] ) {
                GUI.BeginGroup( new Rect( position.width - MenuBar.width - ( ErrorMsg[(int) Errors.DupeChar] ? 228 : 99 ), position.height - 60, 130, 60 ) );//Overlapping Character Rects
                SplitError = OverlapErrorString.Split( '#' );
                GUI.Box( new Rect( 0, 0, 100, 60 ), "" );
                GUI.Label( new Rect( 6, 4, 90, 60 ), SplitError[0] );
                if ( GUI.Button( new Rect( 4, 38, 45, 18 ), SplitError[1] ) ) {
                    ClickedRectInd = FirstOverlapRect;
                    ReFocusBlank = true;
                    CameraOnRect( Rects[ClickedRectInd].rect );
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ) );
                }
                if ( GUI.Button( new Rect( 51, 38, 45, 18 ), SplitError[2] ) ) {
                    ClickedRectInd = SecondOverlapRect;
                    ReFocusBlank = true;
                    CameraOnRect( Rects[ClickedRectInd].rect );
                    GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, ( SpriteEditor ? Rects[ClickedRectInd].fontIndex : 0 ) );
                }
                GUI.EndGroup();
            }

            if ( SpriteSetDialog ) {//SpriteSet Dialog
                GUI.BeginGroup( new Rect( position.width - 150, position.height / 2 - 120, 167, 200 ) ); //Clip SpriteSet Dialog
                GUI.Box( new Rect( 0, 0, 150, 149 + PromptOffset4 ), "" );
                if ( GUI.Button( new Rect( 10, 72, 60, 30 ), "Next" ) ) {
                    AddRect( true, RectFontIndex );
                }
                if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Return && GUI.GetNameOfFocusedControl() == "SpriteIndInput" ) {
                    AddRect( true, RectFontIndex );
                }
                if ( e.type == EventType.KeyDown && e.keyCode == KeyCode.Escape && GUI.GetNameOfFocusedControl() == "SpriteIndInput" ) {
                    SkipRect();
                }

                EditorGUIUtility.LookLikeControls( 40, 60 );
                RectFontIndex = EditorGUI.Popup( new Rect( 10, 10, 130, 20 ), "Font:", RectFontIndex, FontListNames );
                EditorGUIUtility.LookLikeControls( 80, 50 );
                GUI.SetNextControlName( "SpriteIndInput" );
                SpriteIndex = Mathf.Max( EditorGUI.IntField( new Rect( 10, 30, 130, 20 ), "Sprite Index:", SpriteIndex ), 0 );
                EditorGUIUtility.LookLikeControls( 40, 60 );
                defaultPivotPoint = (defaultPivotPointEnum) EditorGUI.EnumPopup( new Rect( 10, 53, 130, 20 ), "Pivot:", defaultPivotPoint );
                if ( GUI.Button( new Rect( 80, 72, 60, 30 ), "Skip" ) ) {
                    SkipRect();
                }
                GUI.BeginGroup( new Rect( 10, 107 + PromptOffset4, 130, 30 ) ); //stop SpriteSet Dialog
                if ( DialogStop ) {
                    if ( GUI.Button( new Rect( 0, 0, 60, 30 ), "Stop" ) ) {
                        PromptOffset4Dest = 0;
                        EndAutoSet();
                        AutoRectList.Clear();
                    }
                    if ( GUI.Button( new Rect( 70, 0, 60, 30 ), "Cancel" ) ) {
                        PromptOffset4Dest = 0;
                    }
                }
                GUI.EndGroup();
                if ( GUI.Button( new Rect( 10, 107, 130, 30 ), "Stop Sprite Set" ) ) {
                    DialogStop = true;
                    PromptOffset4Dest = 30;
                }
                if ( SpriteIndexRepeatList.Count > 1 && AutoSetIndex == 0 ) {
                    if ( GUI.Button( new Rect( 30, 149 + PromptOffset4, 90, 20 ), "Repeat Last" ) ) {
                        RepeatSetting = true;
                        for ( int i = 0; i < SpriteIndexRepeatList.Count; i++ ) {
                            if ( SpriteIndexRepeatList[i].x == -1 ) {
                                AutoRectList.RemoveAt( AutoSetIndex );
                            } else {
                                SpriteIndex = (int) SpriteIndexRepeatList[i].x;
                                RectFontIndex = (int) SpriteIndexRepeatList[i].y;
                                defaultPivotPoint = (defaultPivotPointEnum) ( SpriteIndexRepeatList[i].z );
                                AddRect( true, RectFontIndex );
                            }
                        }
                        RepeatSetting = false;
                        EndAutoSet();
                    }
                }
                GUI.FocusControl( "SpriteIndInput" );
                GUI.EndGroup();
            }
        } //End of font setter

        //Below here is drawing RectPacker GUI
        if ( UsingPacker ) {
            GUI.Box( new Rect( position.width - MenuBar.width, 0, MenuBar.width, MenuBar.height ), "" );/////RightBox
            GUI.BeginGroup( new Rect( 4, 4, position.width - 4, MenuBar.height - 8 ) );//Clip The Menu pics
            GUI.DrawTexture( new Rect( position.width - 8 - MenuPics[2].width, 0, MenuPics[2].width, MenuPics[2].height ), MenuPics[2] );
            GUI.EndGroup();
            GUI.BeginGroup( new Rect( position.width - MenuBar.width, position.height - 80 - PromptOffset1, MenuBar.width, 50 ) ); //BGCol Group
            GUI.Label( new Rect( 10, 0, 130, 40 ), "Background\ncolor:" );
            BGCol = EditorGUI.ColorField( new Rect( 90, 8, 50, 20 ), BGCol );
            GUI.EndGroup();

            GUI.BeginGroup( new Rect( position.width - MenuBar.width + 10, position.height - 70, MenuBar.width, 150 ) ); //Back to menu Group
            GUI.BeginGroup( new Rect( 0, 30 - PromptOffset1, 130, 200 ) ); //Back to menu Group
            if ( MenuPrompt ) {
                if ( GUI.Button( new Rect( 0, 0, 60, 30 ), "Return" ) ) {
                    UsingPacker = false;
                    UsingMenu = true;
                    ResetError();
                    MenuPrompt = false;
                    PromptOffset1Dest = 0;
                    position = new Rect( position.x, position.y - 5, 512, 512 );
                }
                if ( GUI.Button( new Rect( 70, 0, 60, 30 ), "Cancel" ) ) {
                    PromptOffset1Dest = 0;
                }
            }
            GUI.EndGroup();
            if ( GUI.Button( new Rect( 0, 31, 130, 30 ), "Return to Menu" ) ) {
                PromptOffset1Dest = 30;
                MenuPrompt = true;
            }
            GUI.EndGroup();

            GUI.BeginGroup( new Rect( 0, 0, position.width - 150, position.height ) );//Clip The Background Box
            GUI.color = BGCol;
            if ( outTex ) {
                GUI.Box( new Rect( 4 + drawOffsetPos.x, 4 + drawOffsetPos.y, outTex.width + 12, outTex.height + 12 ), "", "theTexBG" );
            } else {
                GUI.Box( new Rect( 4, 4, 256, 256 ), "", "theTexBG" );
            }
            GUI.color = Color.white;
            GUI.EndGroup();

            if ( GUI.Button( new Rect( position.width - 140, 10, 130, 30 ), "Pack!" ) ) {
                ClearLog();
                BeginPack();
            }

            GUI.BeginGroup( new Rect( position.width - 140, 45, 130, 500 ) );
            GUI.Label( new Rect( 0, 0, 130, 20 ), "Sort Rects:" );
            SortMode = GUI.SelectionGrid( new Rect( 0, 20, 130, 75 ), SortMode, Sorts, 2 );
            GUI.Label( new Rect( 0, 110, 130, 22 ), "Packing Method:" );
            PackMode = GUI.SelectionGrid( new Rect( 0, 130, 130, 75 ), PackMode, Packs, 2 );
            AllowNPOT = GUI.Toggle( new Rect( 0, 220, 130, 20 ), AllowNPOT, "Allow NPOT result" );
            AllowRotationTest = GUI.Toggle( new Rect( 0, 240, 130, 20 ), AllowRotationTest, "Allow Rotation test" ); ;
            AnchorSort = GUI.Toggle( new Rect( 0, 260, 130, 20 ), AnchorSort, "Sort Anchor Mode" ); ;
            FitToPOT = GUI.Toggle( new Rect( 0, 280, 130, 20 ), FitToPOT, "Fit to POT Texture" );
            EditorGUIUtility.LookLikeControls( 80, 25 );
            PackBuffer = Mathf.Max( EditorGUI.IntField( new Rect( 0, 305, 130, 20 ), "Rect Buffer:", PackBuffer, "TextField" ), 0 );
            GUI.EndGroup();

            if ( outTex ) {
                GUI.BeginGroup( new Rect( 0, 0, position.width - 150, position.height ) );
                GUI.DrawTexture( new Rect( 10 + drawOffsetPos.x, 10 + drawOffsetPos.y, outTex.width, outTex.height ), outTex );
                GUI.EndGroup();
            }
        }

        if ( ErrorMsg[(int) Errors.NoMaterial] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 75, position.height / 2 - 30, 150, 150 ) ); //Error NoMaterial Group
            GUI.Box( new Rect( 0, 0, 150, 90 ), "" );
            GUI.Label( new Rect( 8, 4, 135, 150 ), "One of your Fonts has no material attatched. Add a material that uses the \"Textured Text Shader\" shader." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.NoTexture] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 75, position.height / 2 - 30, 150, 150 ) ); //Error NoMaterial Group
            GUI.Box( new Rect( 0, 0, 150, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 135, 150 ), "One of your Fonts has a material with no texture map assigned." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.NoSpriteMaterial] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 65, position.height / 2 - 30, 130, 150 ) ); //Error No Sprite Material Group
            GUI.Box( new Rect( 0, 0, 130, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 125, 150 ), "Your sprite has no material and/or texture assigned." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.NoTextMesh] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 71, position.height / 2 - 30, 142, 150 ) ); //Error No TextMesh/Renderer Group
            GUI.Box( new Rect( 0, 0, 142, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 137, 150 ), "Your sprite has no TextMesh and/or no Renderer components." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.NPOT] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 100, position.height / 2 - 30, 200, 60 ) ); //Error NPOT Group
            GUI.Box( new Rect( 0, 0, 200, 60 ), "" );
            GUI.Label( new Rect( 6, 4, 190, 150 ), "Your Font Map is NPOT, Change the Import Settings property for NPOT maps to 'None'." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.ReadWrite] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 100, position.height / 2 - 30, 200, 60 ) ); //Error ReadWrite Group
            GUI.Box( new Rect( 0, 0, 200, 60 ), "" );
            GUI.Label( new Rect( 10, 4, 190, 60 ), "Please set Read/Write Enabled in the texture settings for the Font Map before running." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.Format] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 100, position.height / 2 - 40, 200, 80 ) ); //Error Format Group
            GUI.Box( new Rect( 0, 0, 200, 80 ), "" );
            GUI.Label( new Rect( 10, 4, 185, 80 ), "Please set the Font Map to a compatible format in its Texture Settings (eg. Compressed, Truecolor, RGBA32)." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.Size] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 75, position.height / 2 - 30, 200, 130 ) ); //Error Size Group
            GUI.Box( new Rect( 0, 0, 150, 80 ), "" );
            GUI.Label( new Rect( 8, 4, 135, 130 ), "Your texture Map is larger than the import size, change this in the Import Settings" );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.SameFont] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 90, position.height / 2 - 30, 180, 130 ) ); //Error SameFont Group
            GUI.Box( new Rect( 0, 0, 180, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 170, 60 ), "You have assigned a sprite that has the same font (animation) more than once." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.NoFonts] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 75, position.height / 2 - 30, 150, 130 ) ); //Error NoFonts Group
            GUI.Box( new Rect( 0, 0, 150, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 130, 60 ), "You have assigned a sprite that contains no fonts (animations)." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.MissedFont] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 75, position.height / 2 - 30, 150, 130 ) ); //Error MissedFont Group
            GUI.Box( new Rect( 0, 0, 150, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 130, 60 ), "You have assigned a sprite with a missing font (animation)." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.ShareFont] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 70, position.height / 2 - 30, 140, 130 ) ); //Error ShareFont Group
            GUI.Box( new Rect( 0, 0, 140, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 130, 60 ), "The in-sprite and out-sprite share font (animation) objects." );
            GUI.EndGroup();
        }

        if ( ErrorMsg[(int) Errors.UnevenLength] ) {
            GUI.BeginGroup( new Rect( position.width / 2 - 85, position.height / 2 - 30, 170, 130 ) ); //Error UnevenLength Group
            GUI.Box( new Rect( 0, 0, 170, 60 ), "" );
            GUI.Label( new Rect( 8, 4, 160, 60 ), "The in-sprite and out-sprite have a different number of fonts (animations)." );
            GUI.EndGroup();
        }

        this.Repaint();
    }
        private void DrawInputBehaviorSettings(SerializedProperty settingsArray) {
            if(settingsArray == null || !settingsArray.isArray) return;

            EditorGUILayout.Space();

            EditorGUILayout.HelpBox(
                "You can define a list of Input Behaviors to be shown to the user for modification. If enabled, new controls will be displayed so the user can modify these settings. " +
                "This is useful if you need to allow the user to set certain per-Action sensitivity levels such as Mouse Look Sensitivity."
            , MessageType.Info);

            EditorGUILayout.Space();

            int[] inputBehaviorIds = userData.GetInputBehaviorIds();
            string[] inputBehaviorNames = userData.GetInputBehaviorNames();

            int count = settingsArray.arraySize;
            for(int i = 0; i < count; i++) {

                using(new EditorGUILayoutSection(true, style_mapSetBkg)) {

                    SerializedProperty setting = settingsArray.GetArrayElementAtIndex(i);
                    if(setting == null) continue;

                    GUILayout.Space(20f);
                    SerializedProperty inputBehaviorId = setting.FindPropertyRelative("_inputBehaviorId");
                    DrawPopupProperty(new GUIContent("Input Behavior", "The Input Behavior that will be displayed to the user for modification."), inputBehaviorIds, inputBehaviorNames, inputBehaviorId); // NOTE: mapCategoryId tool tip from Attribute is always NULL!
                    int selectedIndex = System.Array.IndexOf<int>(inputBehaviorIds, inputBehaviorId.intValue);
                    if(selectedIndex < 0) continue;

                    // Display settings

                    SerializedProperty labelLanguageKey = setting.FindPropertyRelative("_labelLanguageKey");

                    SerializedProperty showJoystickAxisSensitivity = setting.FindPropertyRelative("_showJoystickAxisSensitivity");
                    SerializedProperty showMouseXYAxisSensitivity = setting.FindPropertyRelative("_showMouseXYAxisSensitivity");

                    SerializedProperty joystickAxisSensitivityLabelLanguageKey = setting.FindPropertyRelative("_joystickAxisSensitivityLabelLanguageKey");
                    SerializedProperty mouseXYAxisSensitivityLabelLanguageKey = setting.FindPropertyRelative("_mouseXYAxisSensitivityLabelLanguageKey");

                    SerializedProperty joystickAxisSensitivityIcon = setting.FindPropertyRelative("_joystickAxisSensitivityIcon");
                    SerializedProperty mouseXYAxisSensitivityIcon = setting.FindPropertyRelative("_mouseXYAxisSensitivityIcon");

                    SerializedProperty joystickAxisSensitivityMin = setting.FindPropertyRelative("_joystickAxisSensitivityMin");
                    SerializedProperty joystickAxisSensitivityMax = setting.FindPropertyRelative("_joystickAxisSensitivityMax");
                    SerializedProperty mouseXYAxisSensitivityMin = setting.FindPropertyRelative("_mouseXYAxisSensitivityMin");
                    SerializedProperty mouseXYAxisSensitivityMax = setting.FindPropertyRelative("_mouseXYAxisSensitivityMax");

                    EditorGUILayout.PropertyField(labelLanguageKey);
                    
                    EditorGUILayout.PropertyField(showJoystickAxisSensitivity);
                    if(showJoystickAxisSensitivity.boolValue) {
                        EditorGUILayout.PropertyField(joystickAxisSensitivityLabelLanguageKey);
                        EditorGUILayout.PropertyField(joystickAxisSensitivityIcon);
                        DrawFloatProperty(joystickAxisSensitivityMin, 0f, 10000f);
                        DrawFloatProperty(joystickAxisSensitivityMax, 0f, 10000f);
                    }

                    EditorGUILayout.PropertyField(showMouseXYAxisSensitivity);
                    if(showMouseXYAxisSensitivity.boolValue) {
                        EditorGUILayout.PropertyField(mouseXYAxisSensitivityLabelLanguageKey);
                        EditorGUILayout.PropertyField(mouseXYAxisSensitivityIcon);
                        DrawFloatProperty(mouseXYAxisSensitivityMin, 0f, 10000f);
                        DrawFloatProperty(mouseXYAxisSensitivityMax, 0f, 10000f);
                    }
                    
                    EditorGUILayout.Space();

                    // Array control butons
                    GUILayout.Space(20f);
                    using(new EditorGUILayoutSection(false)) {
                        GUILayout.FlexibleSpace();
                        if(GUILayout.Button("Delete", GUILayout.ExpandWidth(false), GUILayout.Width(100f))) {
                            settingsArray.DeleteArrayElementAtIndex(i);
                            break; // exit now to avoid issues
                        }
                    }
                }

                GUILayout.Space(20f);
            }

            EditorGUILayout.Space();
            if(GUILayout.Button("+ Add Input Behavior")) {
                settingsArray.InsertArrayElementAtIndex(settingsArray.arraySize);
                SerializedProperty setting = settingsArray.GetArrayElementAtIndex(settingsArray.arraySize - 1);
                // Clear to defaults
                setting.FindPropertyRelative("_inputBehaviorId").intValue = 0;
                setting.FindPropertyRelative("_labelLanguageKey").stringValue = string.Empty;
                setting.FindPropertyRelative("_showJoystickAxisSensitivity").boolValue = false;
                setting.FindPropertyRelative("_showMouseXYAxisSensitivity").boolValue = false;
                setting.FindPropertyRelative("_joystickAxisSensitivityLabelLanguageKey").stringValue = string.Empty;
                setting.FindPropertyRelative("_mouseXYAxisSensitivityLabelLanguageKey").stringValue = string.Empty;
                setting.FindPropertyRelative("_joystickAxisSensitivityIcon").objectReferenceValue = (Sprite)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("0c9ce4e64fb83764aa394faeeed56210"), typeof(Sprite));
                setting.FindPropertyRelative("_mouseXYAxisSensitivityIcon").objectReferenceValue = (Sprite)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("fc88ce24a47f4014cb0ad237abc8d1dd"), typeof(Sprite));
                setting.FindPropertyRelative("_joystickAxisSensitivityMin").floatValue = 0.0f;
                setting.FindPropertyRelative("_joystickAxisSensitivityMax").floatValue = 2.0f;
                setting.FindPropertyRelative("_mouseXYAxisSensitivityMin").floatValue = 0.0f;
                setting.FindPropertyRelative("_mouseXYAxisSensitivityMax").floatValue = 2.0f;
            }
            EditorGUILayout.Space();
        }
    void DrawIntList(Rect displaySize, SerializedProperty intList, string type)
    {
        EditorGUIUtility.LookLikeControls();
        var currentY = displaySize.y;

        for (int i = 0; i < intList.arraySize; i++)
        {
            Rect lineDisplayRect = new Rect(displaySize.x + displaySize.width - 130, currentY, 100, 16);
            Rect removeButtonRect = new Rect(lineDisplayRect.x + lineDisplayRect.width, currentY, 30, 16);

            int validateFirst = EditorGUI.IntField(lineDisplayRect, intList.GetArrayElementAtIndex(i).intValue);
            if (validateFirst > 1)
            {
                intList.GetArrayElementAtIndex(i).intValue = validateFirst;
            }
            if (GUI.Button(removeButtonRect, "-"))
            {
                intList.DeleteArrayElementAtIndex(i);
                return;
            }
            currentY += 16;
        }
        Rect AddButtonRect = new Rect(displaySize.x, currentY, displaySize.width, 16);

        if (GUI.Button(AddButtonRect, "+ Add New " + type))
        {
            intList.InsertArrayElementAtIndex(intList.arraySize);
        }
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        label = EditorGUI.BeginProperty(position, label, property);
        property.isExpanded = EditorGUILayout.Foldout( property.isExpanded, label );
        if( property.isExpanded )
        {

            EditorGUI.indentLevel += 1;
            place = property.FindPropertyRelative("UnityPlaces");
            number = property.FindPropertyRelative("Number");
            /*if(place.arraySize == 0){
                place.InsertArrayElementAtIndex(0);
            }*/

            for( int i = 0 ; i < place.arraySize; ++i )
            {
                name = "Place "+(i+1);
                GUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(new GUIContent( name));
                GUILayout.Space(-22);
                EditorGUILayout.PropertyField( place.GetArrayElementAtIndex(i));
                GUILayout.Space(5);
                if( GUILayout.Button ("-", EditorStyles.miniButton, GUILayout.ExpandWidth(false) ) )
                {
                    if(i >= 0){
                        List<GameObject> listDelete = new List<GameObject>();
                        for (int j = 0; j < PlacesNPC.Count; j++)
                        {
                            if (PlacesNPC[j] != null && place.GetArrayElementAtIndex(i).objectReferenceValue != null && PlacesNPC[j].name == place.GetArrayElementAtIndex(i).objectReferenceValue.name)
                                listDelete.Add(PlacesNPC[j]);

                        }
                        for(int j = 0; j < listDelete.Count; j++)
                            GameObject.DestroyImmediate(listDelete[j]);

         						place.GetArrayElementAtIndex(i).objectReferenceValue = null;
                        place.DeleteArrayElementAtIndex(i);
                        //PlacesNPC.RemoveAt(i);

                    }
                    //GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                    break;
                }

                GUILayout.Space(5);
                //GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();

            }

            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if( GUILayout.Button("Generate Place", EditorStyles.miniButtonLeft, GUILayout.ExpandWidth(false), GUILayout.Width(100) ) )
            {
                GeneratePlaces();

            }
            if( GUILayout.Button("Add Existing Place", EditorStyles.miniButtonRight, GUILayout.ExpandWidth(false), GUILayout.Width(125) ) )
            {
                place.InsertArrayElementAtIndex(place.arraySize);
                place.GetArrayElementAtIndex(place.arraySize-1 ).objectReferenceValue = null;
                PlacesNPC.Add(null);
                number.intValue += 1;

            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            EditorGUI.indentLevel -= 1;

        }
        EditorGUI.EndProperty();
    }
Example #17
0
    void DrawSimpleList(SerializedProperty list,bool useDraBox)
    {
        EditorGUILayout.PropertyField(list);

        if (list.isExpanded)
        {
            if (useDraBox)
                DrawDragBox(list);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                list.arraySize++;
            }
            if (GUILayout.Button("Clear"))
            {
                list.arraySize=0;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            for (int i = 0; i < list.arraySize; i++)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("-"))
                {
                    list.DeleteArrayElementAtIndex(i);
                    if(useDraBox)
                        list.DeleteArrayElementAtIndex(i);
                }

                if (i < list.arraySize && i >= 0)
                    EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), new GUIContent("", null, ""));

                GUILayout.EndHorizontal();
            }
        }
    }
		public static void Draw (Rect _position, SerializedProperty _arrayProperty, GUIContent _label, eArrayOptions _options)
		{
			int _originalIndentLevel	= EditorGUI.indentLevel;
			int _count					= _arrayProperty.arraySize;
			bool _showNameWithFoldout	= (_options & eArrayOptions.SHOW_NAME_WITH_FOLDOUT) != 0;
			bool _showArraySize			= (_options & eArrayOptions.SHOW_ARRAY_SIZE) != 0;

			// Height used for primitive properties and buttons
			float _singleLineHeight		= EditorGUIUtility.singleLineHeight;
			
			// Calculate rect
			float _positionY			= _position.y;

			// Rect for array name
			Rect _nameRect				= new Rect(_position.x, _positionY, _position.width, _singleLineHeight);
			_positionY					+= (_singleLineHeight + kSpacingPixels);
			
			// Show array name
			if (_showNameWithFoldout)
			{
				_arrayProperty.isExpanded	= EditorGUI.Foldout(_nameRect, _arrayProperty.isExpanded, _label);

				// Indent to next level
				EditorGUI.indentLevel++;
			}
			else
			{
				EditorGUI.LabelField(_nameRect, _label);
			}

			// Is foldout enabled, then dont show the rest of the elements
			if (!_arrayProperty.isExpanded)
			{
				// Reset indentation level
				EditorGUI.indentLevel	= _originalIndentLevel;
				return;
			}

			// Show array size
			if (_showArraySize && _count != 0)
			{
				// Rect for array Length
				Rect _sizeRect		= new Rect(_position.x, _positionY, _position.width, _singleLineHeight);
				_positionY			+= (_singleLineHeight + kSpacingPixels);

				// Check if size value changes
				EditorGUI.BeginChangeCheck();
				int _newSize		= EditorGUI.IntField(_sizeRect, "Size", _count);

				if (EditorGUI.EndChangeCheck())
					_arrayProperty.arraySize	= _newSize;
			}			

			// If there are no elements then we will show button to add elements
			if (_count == 0)
			{
				// Rect for add button
				Rect _addButtonRect	= new Rect(_position.x, _positionY, _position.width, _singleLineHeight);
				_positionY			+= (_singleLineHeight + kSpacingPixels);

				if (GUI.Button(_addButtonRect, "Add"))
					_arrayProperty.InsertArrayElementAtIndex(0);
			}
			else
			{
				// If there are elements then we will show its contents
				for (int _iter = 0; _iter < _count; _iter++)
				{
					// Get element property
					SerializedProperty _elementProperty	= _arrayProperty.GetArrayElementAtIndex(_iter);
					float _elementHeight				= EditorGUI.GetPropertyHeight(_elementProperty);

					// Rect for element, edit buttons
					Rect _elementRect		= new Rect(_position.x, _positionY, _position.width, _elementHeight);
					_positionY				+= _elementHeight;
					Rect _deleteButtonRect	= new Rect(_position.x + _position.width - kEditButtonWidth, _positionY, 
					                                  kEditButtonWidth, _singleLineHeight);
					Rect _addButtonRect		= new Rect(_deleteButtonRect.x - kEditButtonWidth, _positionY, 
					                                kEditButtonWidth, _singleLineHeight);
					_positionY				+= _singleLineHeight + kSpacingPixels;

					// Grouping element and buttons
					EditorGUI.PropertyField(_elementRect,
					                        _elementProperty, 
					                        new GUIContent("# " + (_iter + 1).ToString() + ":"), 
					                        true);
					
					if (GUI.Button(_addButtonRect, "+"))
					{
						_arrayProperty.InsertArrayElementAtIndex(0);
						break;
					}
					
					if (GUI.Button(_deleteButtonRect, "-"))
					{
						_arrayProperty.DeleteArrayElementAtIndex(_iter);
						break;
					}
				}
			}

			// Reset indentation level
			EditorGUI.indentLevel	= _originalIndentLevel;
		}
        private void DrawEventArray(Rect pos, SerializedProperty array, ref Rect labelPos, GUIStyle labelStyle)
        {
            for (int i = 0; i < array.arraySize; ++i)
            {
                labelPos.height = 20;
                var audioEvent =
                    array.GetArrayElementAtIndex(i).FindPropertyRelative("Event").objectReferenceValue as
                        InAudioEventNode;

                if (audioEvent != null)
                    GUI.Label(labelPos, audioEvent.GetName, labelStyle);
                else
                    GUI.Label(labelPos, "Missing event", labelStyle);

                Rect buttonPos = labelPos;
                buttonPos.x = pos.width - 200; //Align to right side
                buttonPos.width = 100;
                if (audioEvent == null)
                    GUI.enabled = false;

                SerializedProperty postAtProperty = array.GetArrayElementAtIndex(i).FindPropertyRelative("PostAt");
                buttonPos.y += 1.5f;
                var currentValue =
                    Convert.ToInt32(EditorGUI.EnumPopup(buttonPos,
                        (EventHookListData.PostEventAt) postAtProperty.enumValueIndex));
                buttonPos.y -= 1.5f;
                if (currentValue != postAtProperty.enumValueIndex)
                    GUI.changed = true;
                postAtProperty.enumValueIndex = currentValue;

                buttonPos.x += 100;
                buttonPos.width = 50;
                if (GUI.Button(buttonPos, "Find"))
                {
                    EditorWindow.GetWindow<EventWindow>().Find(audioEvent);
                }
                GUI.enabled = true;
                buttonPos.x = pos.width - 44;
                buttonPos.width = 35;
                if (GUI.Button(buttonPos, "X"))
                {
                    array.DeleteArrayElementAtIndex(i);
                    GUI.changed = true;
                }
                labelPos.y += LineHeight;
            }
        }
Example #20
0
 void RemoveGameObjectFromList(SerializedProperty gos, int groupIndex, int objectIndex)
 {
     Vector2 vec = new Vector2(groupIndex, objectIndex);
     if(selectedObjectId.vector2Value == vec)
     {
         selectedObjectId.vector2Value = disabledId;
         paintingEnabled = false;
     }
     gos.DeleteArrayElementAtIndex(objectIndex);
 }
Example #21
0
		public static void AddArray(SerializedProperty prop, GUIContent guiContent, bool editHierarchy, bool changeOrder, DrawArrayElement drawArrayElement = null, OnAddToArray onAddToArray = null, DrawArrayElementLabel drawArrayElementLabel = null, bool showHeading = true) {
			int resetIndent = EditorGUI.indentLevel;

			// Array heading
			if (showHeading) {
				GUILayout.BeginHorizontal();
				GUILayout.Space(EditorGUI.indentLevel * indent);
				
				if (drawArrayElement == null) {
					GUILayout.Label(guiContent.text + " (" + prop.arraySize.ToString() + ")", GUILayout.Width(150));
				} else {
					EditorGUILayout.PropertyField(prop, new GUIContent(guiContent.text + " (" + prop.arraySize.ToString() + ")", string.Empty), false, GUILayout.Width(150));
				}
				
				GUILayout.EndHorizontal();
			}
			
			int deleteIndex = -1;
			
			if (drawArrayElement == null || !showHeading) prop.isExpanded = true;
			
			// Draw Array elements
			if (prop.isExpanded) {			
				for(int i = 0; i < prop.arraySize; i++) {
					GUILayout.BeginHorizontal(); // Main
					GUILayout.Space(((EditorGUI.indentLevel + 1) * indent));
					GUILayout.BeginVertical();
					
					element = prop.GetArrayElementAtIndex(i);

					// Label
					GUILayout.BeginHorizontal(); 
				
					if (editHierarchy && GUILayout.Button(new GUIContent("-", "Remove"), changeOrder? EditorStyles.miniButtonLeft: EditorStyles.miniButton, GUILayout.Width(20))){
						deleteIndex = i;
					}
					
					if (changeOrder) {
						if (GUILayout.Button(new GUIContent("<", "Move up"), editHierarchy? EditorStyles.miniButtonMid: EditorStyles.miniButtonLeft, GUILayout.Width(20))) {
							int moveTo = i == 0? prop.arraySize - 1: i - 1;
							prop.MoveArrayElement(i, moveTo);
							prop.isExpanded = true;
						}
							
						if (GUILayout.Button(new GUIContent(">", "Move down"), EditorStyles.miniButtonRight, GUILayout.Width(20))) {
							int moveTo = i == prop.arraySize - 1? 0: i + 1;
							prop.MoveArrayElement(i, moveTo);
							prop.isExpanded = true;
						}
					}
					
					// Calling the DrawArrayElementLabel delegate
					if (drawArrayElementLabel != null) {
						drawArrayElementLabel(element, editHierarchy);
					}
					
					GUILayout.EndHorizontal(); // End Label
					
					// Array Element
					GUILayout.BeginVertical();
					if (element.isExpanded && drawArrayElement != null) {
						drawArrayElement(element, editHierarchy);
					}
					GUILayout.EndVertical();
					
					GUILayout.Space(5);
					
					GUILayout.EndVertical(); // End Style
					GUILayout.EndHorizontal(); // End Main
				}
				
				// Deleting array elements
				if (deleteIndex != -1) prop.DeleteArrayElementAtIndex(deleteIndex);
				
				// Adding array elements
				GUILayout.BeginHorizontal();
				GUILayout.Space(((EditorGUI.indentLevel + 1) * indent) + 4);
				GUILayout.BeginVertical();
				
				if (editHierarchy && GUILayout.Button(new GUIContent("+", "Add"), EditorStyles.miniButton, GUILayout.Width(20))) {
					prop.arraySize ++;
					
					if (onAddToArray != null) onAddToArray(prop.GetArrayElementAtIndex(prop.arraySize - 1));
				}
				
				GUILayout.EndVertical();
				GUILayout.EndHorizontal();
			}
				
			EditorGUI.indentLevel = resetIndent;
		}
Example #22
0
 private void RemoveTransformPathInList(ReorderableList list)
 {
     m_ExtraExposedTransformPaths.DeleteArrayElementAtIndex(list.index);
 }
Example #23
0
        private void ShowMaterialGUI()
        {
            serializedObject.UpdateIfRequiredOrScript();

            EditorGUILayout.Popup(m_MaterialLocation, Styles.MaterialLocationOpt, Styles.MaterialLocation);

            string materialHelp = string.Empty;

            if (!m_MaterialLocation.hasMultipleDifferentValues)
            {
                if (m_Materials.arraySize > 0 && HasEmbeddedMaterials())
                {
                    // we're generating materials inside the prefab
                    materialHelp = Styles.InternalMaterialHelp.text;
                }

                if (targets.Length == 1 && m_Materials.arraySize > 0 && m_MaterialLocation.intValue != 0)
                {
                    materialHelp += " " + Styles.MaterialAssignmentsHelp.text;
                }

                // display the extract buttons
                if (m_MaterialLocation.intValue != 0)
                {
                    if (ExtractMaterialsGUI())
                    {
                        return;
                    }
                }
            }

            if (!string.IsNullOrEmpty(materialHelp))
            {
                EditorGUILayout.HelpBox(materialHelp, MessageType.Info);
            }

            if ((targets.Length == 1 || m_SupportsEmbeddedMaterials.hasMultipleDifferentValues == false) && m_SupportsEmbeddedMaterials.boolValue == false &&
                m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(Styles.NoMaterialMappingsHelp.text, MessageType.Warning);
            }

            // The material remap list
            if (targets.Length == 1 && m_Materials.arraySize > 0 && m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues)
            {
                GUILayout.Label(Styles.ExternalMaterialMappings, EditorStyles.boldLabel);

                if (MaterialRemapOptons())
                {
                    return;
                }

                // The list of material names is immutable, whereas the map of external objects can change based on user actions.
                // For each material name, map the external object associated with it.
                // The complexity comes from the fact that we may not have an external object in the map, so we can't make a property out of it
                for (int materialIdx = 0; materialIdx < m_Materials.arraySize; ++materialIdx)
                {
                    var id       = m_Materials.GetArrayElementAtIndex(materialIdx);
                    var name     = id.FindPropertyRelative("name").stringValue;
                    var type     = id.FindPropertyRelative("type").stringValue;
                    var assembly = id.FindPropertyRelative("assembly").stringValue;

                    SerializedProperty materialProp = null;
                    Material           material     = null;
                    var propertyIdx = 0;

                    for (int externalObjectIdx = 0, count = m_ExternalObjects.arraySize; externalObjectIdx < count; ++externalObjectIdx)
                    {
                        var pair         = m_ExternalObjects.GetArrayElementAtIndex(externalObjectIdx);
                        var externalName = pair.FindPropertyRelative("first.name").stringValue;
                        var externalType = pair.FindPropertyRelative("first.type").stringValue;

                        if (externalName == name && externalType == type)
                        {
                            materialProp = pair.FindPropertyRelative("second");
                            material     = materialProp != null ? materialProp.objectReferenceValue as Material : null;
                            propertyIdx  = externalObjectIdx;
                            break;
                        }
                    }

                    GUIContent nameLabel = EditorGUIUtility.TextContent(name);
                    nameLabel.tooltip = name;
                    if (materialProp != null)
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.ObjectField(materialProp, typeof(Material), nameLabel);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (materialProp.objectReferenceValue == null)
                            {
                                m_ExternalObjects.DeleteArrayElementAtIndex(propertyIdx);
                            }
                        }
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        material = EditorGUILayout.ObjectField(nameLabel, material, typeof(Material), false) as Material;
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (material != null)
                            {
                                var newIndex = m_ExternalObjects.arraySize++;
                                var pair     = m_ExternalObjects.GetArrayElementAtIndex(newIndex);
                                pair.FindPropertyRelative("first.name").stringValue      = name;
                                pair.FindPropertyRelative("first.type").stringValue      = type;
                                pair.FindPropertyRelative("first.assembly").stringValue  = assembly;
                                pair.FindPropertyRelative("second").objectReferenceValue = material;
                            }
                        }
                    }
                }
            }
        }
        private void DrawEditableSerializedPropertyArray(SerializedProperty serializedPropertyArray, string label, int[] values, string[] names) {
            if(serializedPropertyArray == null || !serializedPropertyArray.isArray) return;

            for(int i = 0; i < serializedPropertyArray.arraySize; i++) {
                SerializedProperty prop = serializedPropertyArray.GetArrayElementAtIndex(i);

                using(new EditorGUILayoutSection(false)) {
                    DrawPopupProperty(new GUIContent(label + " " + i), values, names, prop);
                    GUILayout.Space(10f);
                    if(GUILayout.Button("Del", GUILayout.Width(50f))) {
                        serializedPropertyArray.DeleteArrayElementAtIndex(i);
                    }
                }
            }

            EditorGUILayout.Space();
            if(GUILayout.Button("Add " + label)) { // insert new one at end
                serializedPropertyArray.InsertArrayElementAtIndex(serializedPropertyArray.arraySize);
            }
        }
	void ClearMaterialArray(PropType type, SerializedProperty props) {
		for (int i = 0; i < props.arraySize; ++i) {
			var prop = props.GetArrayElementAtIndex(i);
			var nameProp = prop.FindPropertyRelative("first.name");
			string propName = nameProp.stringValue;

			if (!MaterialPropNames.ContainsKey(propName) || MaterialPropNames[propName].type != type) {
				props.DeleteArrayElementAtIndex(i);
				--i;
			}
		}

		MatEditor.OnEnable();
	}
 public static void DrawListLayout(SerializedProperty property)
 {
     EditorGUILayout.PropertyField (property);
     EditorGUI.indentLevel++;
     if (property.isExpanded) {
         for (int i = 0; i < property.arraySize; i++) {
             EditorGUILayout.BeginHorizontal ();
             EditorGUILayout.PropertyField (property.GetArrayElementAtIndex (i), true);
             if (GUILayout.Button (moveButtonContent, EditorStyles.miniButtonLeft, GUILayout.Width(20))) {
                 property.MoveArrayElement (i, i + 1);
             }
             if (GUILayout.Button (duplicateButtonContent, EditorStyles.miniButtonMid, GUILayout.Width(20))) {
                 property.InsertArrayElementAtIndex (i);
             }
             if (GUILayout.Button (deleteButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(20))) {
                 int oldsize = property.arraySize;
                 property.DeleteArrayElementAtIndex (i);
                 if (oldsize == property.arraySize) {
                     property.DeleteArrayElementAtIndex (i);
                 }
             }
             EditorGUILayout.EndHorizontal ();
         }
         if (GUILayout.Button (addButtonContent, EditorStyles.miniButton)) {
             property.arraySize += 1;
         }
     }
     EditorGUI.indentLevel--;
 }
 private void DoApply(SerializedObject so)
 {
     if (this.multipleSprites)
     {
         List <string>      list  = new List <string>();
         List <string>      list2 = new List <string>();
         SerializedProperty serializedProperty = so.FindProperty("m_SpriteSheet.m_Sprites");
         for (int i = 0; i < this.m_RectsCache.Count; i++)
         {
             SpriteRect spriteRect = this.m_RectsCache.RectAt(i);
             if (string.IsNullOrEmpty(spriteRect.name))
             {
                 spriteRect.name = "Empty";
             }
             if (!string.IsNullOrEmpty(spriteRect.originalName))
             {
                 list.Add(spriteRect.originalName);
                 list2.Add(spriteRect.name);
             }
             if (serializedProperty.arraySize < this.m_RectsCache.Count)
             {
                 serializedProperty.InsertArrayElementAtIndex(serializedProperty.arraySize);
             }
             SerializedProperty arrayElementAtIndex = serializedProperty.GetArrayElementAtIndex(i);
             spriteRect.ApplyToSerializedProperty(arrayElementAtIndex);
             EditorUtility.DisplayProgressBar(SpriteEditorWindow.SpriteEditorWindowStyles.saveProgressTitle.text, string.Format(SpriteEditorWindow.SpriteEditorWindowStyles.saveContentText.text, i, this.m_RectsCache.Count), (float)i / (float)this.m_RectsCache.Count);
         }
         while (this.m_RectsCache.Count < serializedProperty.arraySize)
         {
             serializedProperty.DeleteArrayElementAtIndex(this.m_RectsCache.Count);
         }
         if (list.Count > 0)
         {
             PatchImportSettingRecycleID.PatchMultiple(so, 213, list.ToArray(), list2.ToArray());
         }
     }
     else if (this.m_RectsCache.Count > 0)
     {
         SpriteRect spriteRect2 = this.m_RectsCache.RectAt(0);
         so.FindProperty("m_Alignment").intValue                  = (int)spriteRect2.alignment;
         so.FindProperty("m_SpriteBorder").vector4Value           = spriteRect2.border;
         so.FindProperty("m_SpritePivot").vector2Value            = spriteRect2.pivot;
         so.FindProperty("m_SpriteTessellationDetail").floatValue = spriteRect2.tessellationDetail;
         SerializedProperty serializedProperty2 = so.FindProperty("m_SpriteSheet.m_Outline");
         if (spriteRect2.outline != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty2, spriteRect2.outline);
         }
         else
         {
             serializedProperty2.ClearArray();
         }
         SerializedProperty serializedProperty3 = so.FindProperty("m_SpriteSheet.m_PhysicsShape");
         if (spriteRect2.physicsShape != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty3, spriteRect2.physicsShape);
         }
         else
         {
             serializedProperty3.ClearArray();
         }
     }
     EditorUtility.ClearProgressBar();
 }
Example #28
0
    void DrawMultipleSurface(SerializedProperty surfaceList)
    {
        GUILayout.BeginVertical();
        EditorGUILayout.PropertyField(surfaceList);
        if (surfaceList.isExpanded)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                surfaceList.arraySize++;
            }
            if (GUILayout.Button("Clear"))
            {
                surfaceList.arraySize = 0;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            for (int i = 0; i < surfaceList.arraySize; i++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.BeginHorizontal("box");

                EditorGUILayout.Space();
                if (i < surfaceList.arraySize && i >= 0)
                {
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.PropertyField(surfaceList.GetArrayElementAtIndex(i));
                    if (surfaceList.GetArrayElementAtIndex(i).isExpanded)
                    DrawSingleSurface(surfaceList.GetArrayElementAtIndex(i), true);
                    EditorGUILayout.Space();
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                if (GUILayout.Button("-"))
                {
                    surfaceList.DeleteArrayElementAtIndex(i);
                }
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndVertical();
    }
Example #29
0
    public void ChangeColorCount(SerializedProperty _list, int _from, int _to)
    {
        if (_to < 1 || _to > 100)
        {
            return;
        }
        int cnt = Mathf.Abs(_to - _from);
        if (_to > _from)
        {
            // add
            for (int i = 0; i < m_item_count; i++)
            {
                for (int c = 0; c < cnt; c++)
                {
                    _list.InsertArrayElementAtIndex(m_item_count * m_color_count - i * m_color_count);
                }
            }
        }
        else
        {
            // remove
            for (int i = 0; i < m_item_count; i++)
            {
                for (int c = 0; c < cnt; c++)
                {
                    _list.DeleteArrayElementAtIndex(m_item_count * m_color_count - cnt - i * m_color_count);
                }
            }
        }

        m_target.ApplyModifiedProperties();
        if (m_type == PACKAGE_TYPE.ARMOR)
        {
            m_scrypt.UpdateList(_to);
        }
    }
        private bool showVector2IntList(SerializedProperty list, bool foldout)
        {
            int listSize = list.arraySize;
            listSize = EditorGUILayout.IntField("Count", listSize);

            if(listSize != list.arraySize)
            {
                while(listSize > list.arraySize)
                {
                    list.InsertArrayElementAtIndex(list.arraySize);
                }
                while(listSize < list.arraySize)
                {
                    list.DeleteArrayElementAtIndex(list.arraySize - 1);
                }
            }

            if (listSize > 0)
            {
                EditorGUI.indentLevel++;
                foldout = EditorGUILayout.Foldout(foldout, "Point List");
                if (foldout)
                {
                    for(int i = 0; i < list.arraySize; i++)
                    {
                        SerializedProperty element = list.GetArrayElementAtIndex(i);
                        SerializedProperty x = element.FindPropertyRelative("x");
                        SerializedProperty y = element.FindPropertyRelative("y");

                        EditorGUILayout.LabelField("Point " + (i + 1));
                        EditorGUI.indentLevel++;
                        EditorGUILayout.PropertyField(x);
                        EditorGUILayout.PropertyField(y);
                        EditorGUI.indentLevel--;
                    }
                }
                EditorGUI.indentLevel--;
            }

            return foldout;
        }
        private void CheckList(UnityEditor.SerializedProperty targets)
        {
            if (targetsList == null)
            {
                targetsList = new UnityEditorInternal.ReorderableList(serializedObject, targets);

                targetsList.drawHeaderCallback = position => EditorGUI.LabelField(position, "Renderers. All renderers that will be included to outline rendering should be in the list.");

                targetsList.drawElementCallback = (position, item, isActive, isFocused) =>
                {
                    var renderPosition = position;
                    var element        = targets.GetArrayElementAtIndex(item);
                    var rendererItem   = element.FindPropertyRelative("Renderer");
                    var reference      = rendererItem.objectReferenceValue;

                    EditorGUI.PropertyField(renderPosition, element, new GUIContent(reference == null ? "Null" : reference.name), true);
                };

                targetsList.elementHeightCallback = (index) => EditorGUI.GetPropertyHeight(targets.GetArrayElementAtIndex(index));

                targetsList.onRemoveCallback = (list) =>
                {
                    var index = list.index;
                    targets.DeleteArrayElementAtIndex(index);
                    targets.serializedObject.ApplyModifiedProperties();
                };

                targetsList.onAddDropdownCallback = (buttonRect, targetList) =>
                {
                    var outlinable = target as Outlinable;
                    var items      = outlinable.gameObject.GetComponentsInChildren <Renderer>(true);
                    var menu       = new GenericMenu();

                    if (!Application.isPlaying)
                    {
                        menu.AddItem(new GUIContent("Add all"), false, () =>
                        {
                            (target as Outlinable).AddAllChildRenderersToRenderingList();

                            EditorUtility.SetDirty(target);
                        });
                    }

                    menu.AddItem(new GUIContent("Empty"), false, () =>
                    {
                        (target as Outlinable).OutlineTargets.Add(new OutlineTarget());

                        EditorUtility.SetDirty(target);
                    });

                    foreach (var item in items)
                    {
                        var found = false;
                        for (var index = 0; index < targets.arraySize; index++)
                        {
                            var element         = targets.GetArrayElementAtIndex(index);
                            var elementRenderer = element.FindPropertyRelative("Renderer");
                            if (elementRenderer.objectReferenceValue == item)
                            {
                                found = true;
                                break;
                            }
                        }

                        var path = string.Empty;
                        if (item.transform != outlinable.transform)
                        {
                            var parent = item.transform;
                            do
                            {
                                path   = string.Format("{0}/{1}", parent.ToString(), path);
                                parent = parent.transform.parent;
                            }while (parent != outlinable.transform);

                            path = string.Format("{0}/{1}", parent.ToString(), path);

                            path = path.Substring(0, path.Length - 1);
                        }
                        else
                        {
                            path = item.ToString();
                        }

                        GenericMenu.MenuFunction function = () =>
                        {
                            var index = targets.arraySize;
                            targets.InsertArrayElementAtIndex(index);
                            var arrayItem = targets.GetArrayElementAtIndex(index);
                            var renderer  = arrayItem.FindPropertyRelative("Renderer");
                            arrayItem.FindPropertyRelative("CutoutThreshold").floatValue = 0.5f;
                            renderer.objectReferenceValue = item;

                            serializedObject.ApplyModifiedProperties();
                        };

                        if (found)
                        {
                            function = null;
                        }

                        menu.AddItem(new GUIContent(path), found, function);
                    }

                    menu.ShowAsContext();
                };
            }
        }
Example #32
0
	/*
	 * 
	 * Handle the Part that is responsible for adding and removing additional elements
	 * 
	 * 
	 */

	private static void ShowButtons (SerializedProperty list, int index) {
		/*
		 * 
		 * If a new element will be added to the array of gameobjects
		 * 
		 */
		if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
			list.InsertArrayElementAtIndex(index);
		}
		/*
		 * 
		 * An element will be removed from the array of gameobjects
		 * 
		 */
		if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth)) {
			int oldSize = list.arraySize;
			list.DeleteArrayElementAtIndex(index);
			//reset the array size
			if (list.arraySize == oldSize) {
				list.DeleteArrayElementAtIndex(index);
			}
		}
	}
    private void RenderListUI(SerializedProperty listProperty, string label)
    {
        GUILayout.BeginHorizontal();
        isListOpen = EditorGUI.Foldout(GUILayoutUtility.GetRect(50, 20), isListOpen, label, true);
        if (isListOpen)
        {
            if (GUILayout.Button(plusContent, EditorStyles.miniButton, miniButtonWidth))
                listProperty.arraySize++;
            GUILayout.EndHorizontal();

            EditorGUI.indentLevel++;
            for (var index = 0; index < listProperty.arraySize; index++)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(listProperty.GetArrayElementAtIndex(index), new GUIContent(index.ToString()) ,true);
                if (GUILayout.Button(minusContent, EditorStyles.miniButton, miniButtonWidth))
                    listProperty.DeleteArrayElementAtIndex(index);
                GUILayout.EndHorizontal();
            }
            EditorGUI.indentLevel--;
        }
        else
            GUILayout.EndHorizontal();
    }
Example #34
0
 /// <summary>
 /// Cleanly deletes an element from a property thats an array
 /// </summary>
 /// <param name="arrayProp">The array property</param>
 /// <param name="deleteIndex">The index to delete</param>
 public static void DeleteElementFromArray(SerializedProperty arrayProp, int deleteIndex)
 {
     if (arrayProp.isArray) {
         SerializedProperty propToDelete = arrayProp.GetArrayElementAtIndex(deleteIndex);
         //There's a bug with calling DeleteArrayElementAtIndex on a character array, so just copy
         // from the back.
         if (propToDelete.propertyType == SerializedPropertyType.Character) {
             for (int j = deleteIndex; j < arrayProp.arraySize - 1; j++) {
                 arrayProp.GetArrayElementAtIndex(j).intValue = arrayProp.GetArrayElementAtIndex(j + 1).intValue;
             }
             arrayProp.arraySize--;
         } else {
             //For some reason, isExpanded data doesn't travel with the property or something...
             for (int k = deleteIndex; k < arrayProp.arraySize - 1; k++) {
                 arrayProp.GetArrayElementAtIndex(k).isExpanded = arrayProp.GetArrayElementAtIndex(k + 1).isExpanded;
             }
             int startSize = arrayProp.arraySize;
             arrayProp.DeleteArrayElementAtIndex(deleteIndex);
             //Sometimes a single delete only deletes the value and not the actual element
             if (startSize == arrayProp.arraySize) {
                 arrayProp.DeleteArrayElementAtIndex(deleteIndex);
             }
         }
     }
 }
        private void DrawMappingSet(SerializedProperty mapSetsArray) {
            if(mapSetsArray == null || !mapSetsArray.isArray) return;

            int[] mapCategoryIds = userData.GetMapCategoryIds();
            string[] mapCategoryNames = userData.GetMapCategoryNames();
            int[] actionCategoryIds = userData.GetActionCategoryIds();
            string[] actionCategoryNames = userData.GetActionCategoryNames();
            int[] actionIds = userData.GetActionIds();
            string[] actionNames = userData.GetActionNames();

            EditorGUILayout.Space();

            EditorGUILayout.HelpBox(
                "You can define a list of Map Categories to be shown to the user for remapping.\n\n" +
                "You can choose to show one or multiple Map Categories. If you define multiple Map Categories here, " +
                "a new row of buttons will be shown that will allow the user to select a Map Category for which to create input assignments. " +
                "You must define a list of assignable Actions to displayed to the user for each Map Category. You can choose to show the user a list of all user-assignable Actions " +
                "contained in an one or more Action Categories or a customized list of individual Actions."
            , MessageType.Info);

            EditorGUILayout.Space();

            int count = mapSetsArray.arraySize;
            if(count == 0) {
                EditorGUILayout.HelpBox("You must have at least one map category!", MessageType.Error);
            }
            for(int i = 0; i < count; i++) {

                using(new EditorGUILayoutSection(true, style_mapSetBkg)) {

                    SerializedProperty mapSet = mapSetsArray.GetArrayElementAtIndex(i);

                    GUILayout.Space(20f);
                    SerializedProperty mapCategoryId = mapSet.FindPropertyRelative("_mapCategoryId");
                    DrawPopupProperty(new GUIContent("Map Category", "The Map Category that will be displayed to the user for mapping."), mapCategoryIds, mapCategoryNames, mapCategoryId); // NOTE: mapCategoryId tool tip from Attribute is always NULL!
                    int selectedMapCategoryIndex = System.Array.IndexOf<int>(mapCategoryIds, mapCategoryId.intValue);
                    if(selectedMapCategoryIndex < 0) continue;

                    SerializedProperty actionListMode = mapSet.FindPropertyRelative("_actionListMode");
                    EditorGUILayout.PropertyField(actionListMode);

                    EditorGUILayout.Space();

                    if((ControlMapper.MappingSet.ActionListMode)actionListMode.intValue == ControlMapper.MappingSet.ActionListMode.ActionCategory) {

                        EditorGUILayout.LabelField(new GUIContent("Action Categories:", "List each Action Category you want to be displayed for this map category. This will list all user-assignable Actions in that category allowing the user to make assignments for each of these Actions."));
                        EditorGUILayout.Space();

                        SerializedProperty actionCategoryIdsArray = mapSet.FindPropertyRelative("_actionCategoryIds");
                        DrawEditableSerializedPropertyArray(actionCategoryIdsArray, "Action Category", actionCategoryIds, actionCategoryNames);

                    } else {

                        EditorGUILayout.LabelField(new GUIContent("Actions:", "List each Action you want to be displayed for this map category. This will allow the user to make assignments for each of these Actions."));
                        EditorGUILayout.Space();

                        SerializedProperty actionIdsArray = mapSet.FindPropertyRelative("_actionIds");
                        DrawEditableSerializedPropertyArray(actionIdsArray, "Action", actionIds, actionNames);
                    }

                    // Array control butons
                    GUILayout.Space(20f);
                    using(new EditorGUILayoutSection(false)) {
                        GUILayout.FlexibleSpace();
                        bool guiEnabled = GUI.enabled;
                        if(i == 0) GUI.enabled = false; // don't allow deleting the first entry
                        if(GUILayout.Button("Delete", GUILayout.ExpandWidth(false), GUILayout.Width(100f))) {
                            mapSetsArray.DeleteArrayElementAtIndex(i);
                            break; // exit now to avoid issues
                        }
                        if(i == 0) GUI.enabled = guiEnabled;
                    }
                }

                GUILayout.Space(20f);
            }

            EditorGUILayout.Space();
            if(GUILayout.Button("+ Add Map Category")) {
                mapSetsArray.InsertArrayElementAtIndex(mapSetsArray.arraySize);
            }
            EditorGUILayout.Space();
        }
Example #36
0
        public override void OnInspectorGUI()
        {
            List <GameObject> prefabGameObjects = new List <GameObject>();

            GameObject[] sceneGameObjects = new GameObject[0];

            //For comparing \Prefabs\Essential prefabs to scene objects by name, if prefab asset is'nt in scene, we instantiate it
            // Not used by now, but might imporve in the future.
            //if (GUILayout.Button("Check Prefabs"))
            //{
            //    prefabGameObjects = LoadAllPrefabsOfType(@"Assets\Prefabs\Essential");
            //    sceneGameObjects = FindObjectsOfType<GameObject>();
            //    foreach (GameObject prefab in prefabGameObjects)
            //    {

            //        if (!GameObject.Find(prefab.name))
            //        {
            //            GameObject instatedObject = Instantiate(prefab);
            //            instatedObject.name = prefab.name;
            //        }

            //    }
            //}
            GetTarget = new SerializedObject(tilemapChangerBrush);
            ThisList  = GetTarget.FindProperty("tilemapConnections");
            GetTarget.Update();

            EditorGUILayout.Space();
            EditorGUILayout.Space();

            for (int i = 0; i < ThisList.arraySize; i++)
            {
                SerializedProperty MyListRef = ThisList.GetArrayElementAtIndex(i);

                SerializedProperty myConnectionTilemap  = MyListRef.FindPropertyRelative("connectionTilemap");
                SerializedProperty myConnectionTileBase = MyListRef.FindPropertyRelative("connectionTileBase");

                // Choose to display automatic or custom field types. This is only for example to help display automatic and custom fields.
                EditorGUILayout.LabelField("Tilemap that you want to place the tile, tile that you want to place");
                EditorGUILayout.BeginHorizontal();
                myConnectionTilemap.objectReferenceValue  = (Tilemap)EditorGUILayout.ObjectField(myConnectionTilemap.objectReferenceValue, typeof(Tilemap), false);
                myConnectionTileBase.objectReferenceValue = (TileBase)EditorGUILayout.ObjectField(myConnectionTileBase.objectReferenceValue, typeof(TileBase), false);
                if (GUILayout.Button("Remove This Index (" + i.ToString() + ")", GUILayout.Width(200)))
                {
                    ThisList.DeleteArrayElementAtIndex(i);
                }
                EditorGUILayout.EndHorizontal();
                //EditorGUILayout.BeginHorizontal();
                //EditorGUIUtility.labelWidth = 50;

                //EditorGUILayout.EndHorizontal();

                EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
            }

            EditorGUILayout.Space();
            //Or add a new item to the List<> with a button
            EditorGUILayout.LabelField("Add a new item with a button");

            if (GUILayout.Button("Add New"))
            {
                tilemapChangerBrush.tilemapConnections.Add(new TilemapChangerBrush.TilemapConnection());
            }
            //Apply the changes to our list
            GetTarget.ApplyModifiedProperties();
        }
Example #37
0
	public override void OnInspectorGUI()
	{
		//serializedObject.Update();

		//EditorGUIUtility.LookLikeInspector();

		field_propertyReceivers = serializedObject.FindProperty("Recievers");

		bool needMoreReceivers = false;

		List<Receiver> recievers = ((Transmitter)target).Receivers;
		if (Event.current.type == EventType.Repaint)
		{
			if (recievers.Count == 0 || recievers[recievers.Count - 1].GameObject != null)
			{
				Debug.Log("omg " + recievers.Count + " " + (recievers.Count > 0 ? recievers[recievers.Count - 1].GameObject.ToString() : ""));
				recievers.Add(new Receiver());
				//serializedObject.ApplyModifiedProperties();
			}
			else
			{
				Debug.Log(recievers[recievers.Count - 1].GameObject.ToString());
			}
			//if (field_propertyReceivers.arraySize == 0 || field_propertyReceivers.GetArrayElementAtIndex(field_propertyReceivers.arraySize - 1).FindPropertyRelative("GameObject").objectReferenceValue == null)
			//{
			//    //((Transmitter)target).Recievers.Add(new Reciever());
			//    //((Transmitter)target).Recievers.Add(1);
			//    //serializedObject.Update();
			//    field_propertyReceivers.arraySize++;
			//    field_propertyReceivers.GetArrayElementAtIndex(field_propertyReceivers.arraySize - 1).objectReferenceValue = null;
			//    //field_propertyReceivers.InsertArrayElementAtIndex(field_propertyReceivers.arraySize - 1);
			//    //field_propertyReceivers.serializedObject.ApplyModifiedProperties();
			//    //field_propertyReceivers.GetArrayElementAtIndex(field_propertyReceivers.arraySize - 1).objectReferenceValue = (object)(new Reciever());
			//}
		}
		//base.OnInspectorGUI();

		//EditorGUILayout.PropertyField(field_propertyOmg);
		//while (field_propertyReceivers.Next(true))
		//{
		//    EditorGUILayout.PropertyField(field_propertyReceivers);
		//}
		//if (field_propertyReceivers == null)
		//{
		//    GUILayout.Label("F*****G NULL");
		//    GUILayout.Label(((Transmitter)target).Recievers.Count + " - F*****G?!");
		//}

		//List<Reciever> recievers = ((Transmitter)target).Recievers;
		//for (int i = 0; i < recievers.Count; i++)
		//{

		//}

		GUILayout.Label(field_propertyReceivers.arraySize + " recievers");
		GUILayout.Label(recievers.Count + " actual recievers");

		for (int i = 0; i < field_propertyReceivers.arraySize; i++)
		{
			SerializedProperty reciever = field_propertyReceivers.GetArrayElementAtIndex(i);
			SerializedProperty recieverGameObject = reciever.FindPropertyRelative("GameObject");
			SerializedProperty recieverMethod = reciever.FindPropertyRelative("Method");
			SerializedProperty recieverParameter = reciever.FindPropertyRelative("Parameter");

			if (recieverGameObject.objectReferenceValue == null && i != field_propertyReceivers.arraySize - 1)
			{
				int oldSize = field_propertyReceivers.arraySize;
				field_propertyReceivers.DeleteArrayElementAtIndex(i);
				if (oldSize == field_propertyReceivers.arraySize)
				{
					field_propertyReceivers.DeleteArrayElementAtIndex(i);
				}
				i--;
				continue;
			}
			//if (recieverGameObject.objectReferenceValue != null && i == field_propertyReceivers.arraySize - 1)
			//{
			//    needMoreRecivers = true;
			//}
			//if (recieverGameObject.objectReferenceValue != null && i == field_propertyReceivers.arraySize - 1)
			//{
			//    //((Transmitter)target).Recievers.Add(new Reciever());
			//    field_propertyReceivers.InsertArrayElementAtIndex(field_propertyReceivers.arraySize);
			//}

			//reciever;
			//if (recieverGameObject == null)
				//EditorGUILayout.PropertyField(reciever);
			//if (recieverGameObject != null)
			EditorGUILayout.PropertyField(recieverGameObject);
			if (recieverGameObject.objectReferenceValue != null)
				EditorGUILayout.PropertyField(recieverMethod, true);
			if (recieverMethod.stringValue != "")
				EditorGUILayout.PropertyField(recieverParameter, true);
			EditorGUILayout.Space();
		}
		//if (GUILayout.Button("+", EditorStyles.miniButton))
	}