Exemplo n.º 1
0
 public static void ShowSelectedAvatarStats()
 {
     if (Selection.gameObjects.Length == 1)
     {
         var selectedTransform = Selection.gameObjects[0].transform;
         var avatar            = selectedTransform.GetComponent <UMAAvatarBase>();
         while (avatar == null && selectedTransform.parent != null)
         {
             selectedTransform = selectedTransform.parent;
             avatar            = selectedTransform.GetComponent <UMAAvatarBase>();
         }
         if (avatar != null)
         {
             SkinnedMeshRenderer sk = avatar.gameObject.GetComponentInChildren <SkinnedMeshRenderer>();
             if (sk != null)
             {
                 List <string> info = new List <string>
                 {
                     sk.gameObject.name,
                     "Mesh index type: " + sk.sharedMesh.indexFormat.ToString(),
                     "VertexLength: " + sk.sharedMesh.vertices.Length,
                     "Submesh Count: " + sk.sharedMesh.subMeshCount
                 };
                 for (int i = 0; i < sk.sharedMesh.subMeshCount; i++)
                 {
                     int[] tris = sk.sharedMesh.GetTriangles(i);
                     info.Add("Submesh " + i + " Tri count: " + tris.Length);
                 }
                 Rect R = new Rect(200.0f, 200.0f, 300.0f, 600.0f);
                 DisplayListWindow.ShowDialog("Mesh Info", R, info);
             }
         }
     }
 }
Exemplo n.º 2
0
        void CellGUI(Rect cellRect, TreeViewItem <AssetTreeElement> item, AssetColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            if (item.data.depth == 0)
            {
                HeaderCellGUI(cellRect, item, column, ref args);
                return;
            }

            AssetItem        ai      = item.data.ai;
            AssetTreeElement element = item.data;

            switch (column)
            {
            case AssetColumns.Selection:
            {
                // EditorGUI.Toggle(cellRect, item.data.ai._SerializedItem != null);
                bool newVal = EditorGUI.Toggle(cellRect, element.Checked);
                if (newVal != element.Checked)
                {
                    element.Checked = newVal;
                    RecalcTypeChecks(element.type);
                }
            }
            break;

            case AssetColumns.Type:
            {
                EditorGUI.LabelField(cellRect, element.type.Name);
            }
            break;

            case AssetColumns.Always:
            {
                cellRect.x     += kCheckboxOffset;
                cellRect.width -= kCheckboxOffset;
                bool clicked = EditorGUI.Toggle(cellRect, ai.IsAlwaysLoaded);
                if (clicked != ai.IsAlwaysLoaded)
                {
                    ai.IsAlwaysLoaded = clicked;
                    UMAAssetIndexer.Instance.ForceSave();
                }
            }
            break;

            case AssetColumns.IsResource:
            {
                cellRect.x     += kCheckboxOffset;
                cellRect.width -= kCheckboxOffset;
                EditorGUI.Toggle(cellRect, ai.IsResource);
            }
            break;

            case AssetColumns.Name:
            {
                // Do toggle
                Rect toggleRect = cellRect;
                toggleRect.x    += GetContentIndent(item);
                toggleRect.width = kToggleWidth;
                //if (toggleRect.xMax < cellRect.xMax)
                //	item.data.enabled = EditorGUI.Toggle(toggleRect, item.data.enabled); // hide when outside cell rect

                // Default icon and label
                args.rowRect = cellRect;
                base.RowGUI(args);
            }
            break;

            case AssetColumns.IsAddressable:
            {
                cellRect.x     += kCheckboxOffset;
                cellRect.width -= kCheckboxOffset;
                EditorGUI.Toggle(cellRect, ai.IsAddressable);
            }
            break;

            case AssetColumns.Group:
                EditorGUI.LabelField(cellRect, ai.AddressableGroup);
                break;

            case AssetColumns.Labels:
            {
                if (!string.IsNullOrEmpty(ai.AddressableLabels))
                {
                    Rect Button = new Rect(cellRect);
                    Button.width   = 32;
                    Button.height -= 2;

                    if (GUI.Button(Button, "View", EditorStyles.toolbarButton))
                    {
                        List <string> labels = new List <string>();
                        labels.AddRange(ai.AddressableLabels.Split(';'));
                        DisplayListWindow.ShowDialog("Addressable Labels", owningWindow.position, labels);
                    }
                    cellRect.x     += 32;
                    cellRect.width -= 32;
                    EditorGUI.LabelField(cellRect, ai.AddressableLabels);
                }
            }
            break;

            case AssetColumns.Buttons:
            {
                float BtnWidth   = (cellRect.width / 3) - (kToggleWidth * 2);
                Rect  ButtonRect = new Rect(cellRect);
                ButtonRect.width = BtnWidth;

                if (GUI.Button(ButtonRect, "Inspect", EditorStyles.toolbarButton))
                {
                    UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(ai._Path);
                    InspectorUtlity.InspectTarget(o);
                }

                /*
                 * ButtonRect.x = ButtonRect.x + BtnWidth;
                 * if (item.data.ai._SerializedItem == null)
                 * {
                 *      if(GUI.Button(ButtonRect, "Add Ref", EditorStyles.toolbarButton))
                 *      {
                 *              ai.CacheSerializedItem();
                 *              Repaint();
                 *      }
                 * }
                 * else
                 * {
                 *      if(GUI.Button(ButtonRect, "Rmv Ref",EditorStyles.toolbarButton))
                 *      {
                 *              ai.ReleaseItem();
                 *              Repaint();
                 *      }
                 * }
                 */
#if UMA_ADDRESSABLES
                if (ai.Item is UMATextRecipe)
                {
                    UMATextRecipe recipe = ai.Item as UMATextRecipe;

                    if (owningWindow.LoadedLabels.Contains(recipe.AssignedLabel))
                    {
                        ButtonRect.x     = ButtonRect.x + ButtonRect.width;
                        ButtonRect.width = 110;

                        if (GUI.Button(ButtonRect, "Update Groups", EditorStyles.toolbarButton))
                        {
                            UMAAssetIndexer.Instance.AddRecipeGroup(recipe);
                            owningWindow.LoadedLabels.Add(recipe.AssignedLabel);
                        }
                    }
                    else
                    {
                        ButtonRect.x     = ButtonRect.x + ButtonRect.width;
                        ButtonRect.width = 110;

                        if (GUI.Button(ButtonRect, "Make Addressable", EditorStyles.toolbarButton))
                        {
                            UMAAssetIndexer.Instance.AddRecipeGroup(recipe);
                            owningWindow.LoadedLabels.Add(recipe.AssignedLabel);
                        }
                    }
                }
#endif
                ButtonRect.x     = ButtonRect.x + ButtonRect.width;
                ButtonRect.width = 32;
                if (GUI.Button(ButtonRect, "Ping", EditorStyles.toolbarButton))
                {
                    UnityEngine.Object o = AssetDatabase.LoadMainAssetAtPath(ai._Path);
                    EditorGUIUtility.PingObject(o);
                }

                ButtonRect.x     = ButtonRect.x + 32;
                ButtonRect.width = kToggleWidth;
                if (GUI.Button(ButtonRect, "X", EditorStyles.toolbarButton))
                {
                    // remove from index.
                    // remove from tree.

                    List <AssetTreeElement> RemoveMe = new List <AssetTreeElement>();
                    UMAAssetIndexer.Instance.RemoveAsset(ai._Type, ai._Name);
                    RemoveMe.Add(item.data);
                    this.treeModel.RemoveElements(RemoveMe);
                    owningWindow.RecountTypes();
                    RecalcTypeChecks(element.type);
                    Repaint();
                }
            }
            break;
            }
        }