Esempio n. 1
0
        private static void HandleSelectionChanged()
        {
            EditorApplication.delayCall += () =>
            {
                // Try to release instances of the viewer.
                var selection = Selection.instanceIDs
                                .Select(EditorUtility.InstanceIDToObject)
                                .Where(obj => obj is UTinyTypeViewer)
                                .Cast <UTinyTypeViewer>()
                                .ToList();
                var toDestroy = Pooling.ListPool <UTinyTypeViewer> .Get();

                try
                {
                    foreach (var instance in Instances)
                    {
                        if (selection.Contains(instance) || UTinyInspector.IsBeingInspected(instance))
                        {
                            continue;
                        }
                        toDestroy.Add(instance);
                    }
                    foreach (var viewer in toDestroy)
                    {
                        Instances.Remove(viewer);
                        DestroyImmediate(viewer, false);
                    }
                }
                finally
                {
                    Pooling.ListPool <UTinyTypeViewer> .Release(toDestroy);
                }
            };
        }
Esempio n. 2
0
 public static void RepaintAll()
 {
     foreach (var window in s_ActiveWindows)
     {
         window.Repaint();
     }
     UTinyInspector.RepaintAll();
 }
        public override void OnInspectorGUI()
        {
            UnityEditorInternal.ComponentUtility.MoveComponentUp(target as UTinyEntityView);

            EditorGUILayout.HelpBox($"Editing in {UTinyConstants.ApplicationName} must be done through the {UTinyConstants.ApplicationName} Inspector", MessageType.Info);
            if (GUILayout.Button($"Go to {UTinyConstants.ApplicationName} Inspector"))
            {
                UTinyInspector.FocusOrCreateWindow();
            }
        }
Esempio n. 4
0
        public static void InvalidateDataModel()
        {
            EntityGroupManager?.RecreateEntityGroupGraphs();

            foreach (var window in s_ActiveWindows)
            {
                window.m_TreeView.Invalidate();
                window.Repaint();
            }
            UTinyInspector.RepaintAll();
        }
 protected override void RenameEnded(RenameEndedArgs args)
 {
     if (args.acceptedRename)
     {
         var item      = FindItem(args.itemID, rootItem);
         var node      = item as IEntityTreeItem;
         var entityRef = node.EntityRef;
         var entity    = entityRef.Dereference(m_Context.Registry);
         entity.Name      = args.newName;
         node.EntityRef   = (UTinyEntity.Reference)entity;
         item.displayName = args.newName;
         UTinyInspector.RepaintAll();
     }
 }
Esempio n. 6
0
        public static void InvalidateSceneGraph()
        {
            foreach (var entityGroup in LoadedEntityGroups)
            {
                var graph = EntityGroupManager.GetSceneGraph(entityGroup);
                graph.CommitChanges();
            }

            foreach (var window in s_ActiveWindows)
            {
                window.m_TreeView.Invalidate();
                window.Repaint();
            }
            UTinyInspector.RepaintAll();
        }
        protected override void OnItemClicked(UTinyType type)
        {
            var module = ValueToModules[type];

            foreach (var entity in Entities)
            {
                entity.GetOrAddComponent((UTinyType.Reference)type);
            }

            if (!IsIncluded(module))
            {
                Debug.Log($"{UTinyConstants.ApplicationName}: The '{module.Name}' module was included to the project because the '{type.Name}' component was added to an entity.");
            }
            MainModule.AddExplicitModuleDependency((UTinyModule.Reference)module);
            UTinyHierarchyWindow.InvalidateDataModel();
            UTinyInspector.RepaintAll();
        }
Esempio n. 8
0
        private void ShowRemoveComponent(UTinyType.Reference typeRef)
        {
            var type = typeRef.Dereference(Registry);

            if ((null == type || type.TypeCode == UTinyTypeCode.Component) && TargetType == typeof(UTinyEntity))
            {
                var rect = EditorGUILayout.GetControlRect(false, GUILayout.Width(16.0f));
                if (GUI.Button(rect, UTinyIcons.X_Icon_8, UTinyStyles.MiddleCenteredLabel))
                {
                    var targets = Targets.Cast <UTinyEntity>().ToList();
                    EditorApplication.delayCall += () =>
                    {
                        foreach (var entity in targets.Cast <UTinyEntity>())
                        {
                            entity.RemoveComponent(typeRef);
                        }
                        UTinyHierarchyWindow.InvalidateDataModel();
                        UTinyInspector.RepaintAll();
                    };
                }
                GUILayout.Space(5.0f);
            }
        }
Esempio n. 9
0
 protected InspectorBackend(UTinyInspector inspector)
 {
     m_Inspector = inspector;
     Targets     = new List <IPropertyContainer>();
 }
Esempio n. 10
0
 public UIElementsBackend(UTinyInspector inspector) : base(inspector)
 {
 }
 public IMGUIBackend(UTinyInspector inspector) : base(inspector)
 {
 }
 public static void RepaintAllWindows()
 {
     UTinyProjectWindow.RepaintAll();
     UTinyInspector.RepaintAll();
     UTinyHierarchyWindow.RepaintAll();
 }
        private void DoLayout()
        {
            DoLayoutToolbar();

            if (UTinyEditorApplication.ContextType == EditorContextType.None)
            {
                // No project is open
                DoLayoutNoOpenProject();
            }
            else
            {
                DoLayoutTabs();

                IDrawable panel;

                switch (m_TabType)
                {
                case TabType.Settings:
                {
                    panel = UTinyEditorApplication.ContextType == EditorContextType.Project
                            ? (IDrawable)m_ProjectSettingsPanel
                            : m_ModuleSettingsPanel;
                }
                break;

                case TabType.Modules:
                {
                    panel = m_ModulePanel;
                }
                break;

                case TabType.Scenes:
                {
                    panel = m_EntityGroupPanel;
                }
                break;

                case TabType.Types:
                {
                    panel = m_TypePanel;
                }
                break;

                case TabType.Code:
                {
                    panel = m_CodePanel;
                }
                break;

                case TabType.Assets:
                {
                    panel = m_AssetPanel;
                }
                break;

                case TabType.BuildReport:
                {
                    panel = m_BuildReportPanel;
                }
                break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (null == panel)
                {
                    return;
                }

                if (panel.DrawLayout())
                {
                    UTinyInspector.RepaintAll();
                    Repaint();
                }
            }
        }