/// <summary>
    /// Load the proper mesh of the last clicked selected item.
    /// </summary>
    /// <param name="NowClickedIndex"></param>
    void UpdateMeshLoaded(int NowClickedIndex)
    {
        if (soData.record.Count <= 0)
        {
            return;
        }
        if (FilteredModels.Count <= 0)
        {
            return;
        }
        if (selectedIndex.Count <= 0)
        {
            return;
        }

        //Debug.Log("Try to Check Mesh" + FilteredModels.Count.ToString() + " " + NowClickedIndex.ToString());

        if (NowClickedIndex == -1)
        {
            NowClickedIndex = soData.LastClickedIndex;
        }

        //Debug.Log("Try to Check Mesh" + FilteredModels[NowClickedIndex].ModelID.ToString());

        bool LikelyLostFocus   = (selectedIndex.Count == 1 && soData.LastClickedIndex == 0);
        bool ForceUpdate       = (NowClickedIndex == -1);
        bool ClickedOnSameItem = (NowClickedIndex == soData.LastClickedIndex);

        //  if ((!LikelyLostFocus && !ClickedOnSameItem) || ForceUpdate)
        {
            //Debug.Log("Loading Display Mesh ID: " + FilteredModels[NowClickedIndex].ModelID.ToString());
            myBareMesh = SpawnDfModel.GetBareMeshFromId(FilteredModels[NowClickedIndex].ModelID);
        }

        bNeedsRedraw            = true;
        soData.LastClickedIndex = NowClickedIndex;
        EditorUtility.SetDirty(this);
    }
    /// <summary>
    /// Prints debug buttons for editor at bottom.
    /// </summary>
    void PrintDebugEditorButtons()
    {
        EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(false));

        float buttonWidth  = 400;
        float buttonHeight = 30;

        if (GUILayout.Button("Instantiate Last Selected Item", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
        {
            SpawnDfModel.SpawnModel(FilteredModels[soData.LastClickedIndex].ModelID);
        }

        /*
         * if (GUILayout.Button("Clear Entire Model Array", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
         * {
         *  soData.record = new List<DfModelRecord>();
         *  soData.AddRecordById(0);
         *  soData.LastClickedIndex = 0;
         *  FilteredModels = soData.record;
         *  selectedIndex = new List<int>();
         *  selectedIndex.Add(0);
         *  UpdateFilteredList();
         * }
         *
         * if (GUILayout.Button("Populate 1000 Items on Model Array", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
         * {
         *  int Count = 0;
         *  int Index = soData.record.Count - 1;
         *
         *  //soData.AddRecordById(60604);
         *  //soData.AddRecordById(62325);
         *  //soData.AddRecordById(74067);
         *
         *
         *  while (Count < 1000)
         *  {
         *      if (soData.AddRecordById(Index))
         *      {
         *          Count++;
         *      }
         *      Index++;
         *      if (Index % 100 == 0)
         *      {
         *          Debug.Log("Finished index: " + Index.ToString());
         *      }
         *  }
         *
         * }
         *
         * if (GUILayout.Button("Populate ALL Model Items", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
         * {
         *  soData.AddAllRecords();
         *  soData.LastClickedIndex = 0;
         *  FilteredModels = soData.record;
         *  selectedIndex = new List<int>();
         *  selectedIndex.Add(0);
         *  UpdateFilteredList();
         * }
         *
         *
         * if (GUILayout.Button("Ready Database for Saving", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
         * {
         *  EditorUtility.SetDirty(soData);
         * }
         *
         * if (GUILayout.Button("Refresh entire label listings", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
         * {
         *  soData.GetAllCurrentLabels();
         * }
         */
        if (GUILayout.Button("Print selected items", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
        {
            EditorUtility.SetDirty(soData);
            Debug.Log("---===Selected Index===---");
            for (int i = 0; i < selectedIndex.Count; i++)
            {
                Debug.Log("Index: " + selectedIndex[i].ToString());
            }
            Debug.Log("---===END Selected Index===---");
        }

        if (GUILayout.Button("Save Assets", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
        {
            SaveData();
        }

        if (GUILayout.Button("Load Assets", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
        {
            //EditorUtility.OpenFilePanel("MyTitle", Application.dataPath, "*.xml");
            LoadData();
        }

        EditorGUILayout.EndHorizontal();
    }