コード例 #1
0
ファイル: InspectorTool.cs プロジェクト: gicait/ur-scape
    private void OnLinePanelToggleChange(bool isOn)
    {
        outputPanel.SetPanel(inspectorOutput.transform);

        if (isOn)
        {
            inspectorType = InspectorType.Line;
            inspectorOutput.ActivateEntryInfo(inspectorType);

            ActivatePanels(isOn);
            lineInspectorPanel.UpdateControlPtsAndInspectionDel();

            if (lineInspectorPanel.lineInspectorPanelFirstActive)
            {
                lineInspectorPanel.AddDefaultLineInspection();
                lineInspectorPanel.ComputeAndUpdateLineProperties();
            }

            foreach (var layer in gridLayerController.mapLayers)
            {
                OnShowGrid(layer, true);
            }

            // Update transect chart
            lineInspectorPanel.UpdateTransectLineInfoAndAllGridDatas(lineInfos[lineInspector.CurrLineInspection]);
        }
        areaInspector.ShowAreaLines(false, areaInfos);
    }
コード例 #2
0
        public override void OnEnable()
        {
            var target      = (IHVImageFormatImporter)base.target;
            var assetTarget = base.assetTarget;

            assetPath = AssetDatabase.GetAssetPath(assetTarget);

            importerIsSRGB = serializedObject.FindProperty("m_sRGBTexture");

            textureData = ParseTextureData(target.userData);

            switch (System.IO.Path.GetExtension(assetPath).ToLower())
            {
            case ".dds":
                if ((base.assetTarget as Texture) == null)
                {
                    inspectorType = InspectorType.Failed;
                }
                else
                {
                    inspectorType = InspectorType.DDS;
                }

                break;

            default:
                defaultEditor = Editor.CreateEditor(target);
                inspectorType = InspectorType.Default;
                break;
            }
        }
コード例 #3
0
        /// <summary>
        ///   Draws an inspector for the passed attribute table.
        /// </summary>
        /// <param name="inspectorType">Type to draw inspector controls for.</param>
        /// <param name="attributeTable">Attribute to draw inspector for.</param>
        /// <param name="inspectorTypeTable"></param>
        /// <param name="blueprintManager"></param>
        public static void AttributeTableField(
            InspectorType inspectorType,
            IAttributeTable attributeTable,
            InspectorTypeTable inspectorTypeTable,
            IBlueprintManager blueprintManager)
        {
            foreach (var inspectorProperty in inspectorType.Properties)
            {
                // Get current value.
                object currentValue = attributeTable.GetValueOrDefault(
                    inspectorProperty.Name,
                    inspectorProperty.Default);

                // Draw inspector property.
                object newValue = LogicInspectorPropertyField(
                    inspectorProperty,
                    currentValue,
                    inspectorTypeTable,
                    blueprintManager);

                // Set new value if changed.
                if (!Equals(newValue, currentValue))
                {
                    attributeTable.SetValue(inspectorProperty.Name, newValue);
                }
            }
        }
コード例 #4
0
        public void TestDeinitRemovesChildEntity()
        {
            var              entityManager   = this.testGame.EntityManager;
            const string     TestBlueprintId = "TestBlueprint";
            BlueprintManager blueprintManager;

            this.testGame.BlueprintManager = blueprintManager = new BlueprintManager();
            blueprintManager.AddBlueprint(TestBlueprintId, new Blueprint());

            TestInspectorTypeWithEntityProperty testType = new TestInspectorTypeWithEntityProperty();
            var                 testInspectorType        = InspectorType.GetInspectorType(typeof(TestInspectorTypeWithEntityProperty));
            IAttributeTable     configuration            = new AttributeTable();
            EntityConfiguration childConfiguration       = new EntityConfiguration {
                BlueprintId = TestBlueprintId
            };

            configuration.SetValue(TestInspectorTypeWithEntityProperty.AttributeMember1, childConfiguration);

            // Init.
            InspectorUtils.InitFromAttributeTable(entityManager, testInspectorType, testType, configuration);

            // Check that child entity was created.
            Assert.AreNotEqual(0, testType.EntityMember);

            // Deinit.
            InspectorUtils.Deinit(entityManager, testInspectorType, testType);

            // Check that child entity was removed.
            Assert.IsTrue(entityManager.EntityIsBeingRemoved(testType.EntityMember));
        }
コード例 #5
0
        public void TestDeserializationFromAttributeTable()
        {
            IAttributeTable attributeTable       = new AttributeTable();
            AttributeTable  entityAttributeTable = new AttributeTable();
            const string    TestValueString      = "Test";

            entityAttributeTable.SetValue(TestComponent.AttributeTestString, TestValueString);
            EntityConfiguration entityConfiguration = new EntityConfiguration
            {
                BlueprintId   = TestBlueprintId,
                Configuration = entityAttributeTable
            };

            attributeTable.SetValue(TestData.AttributeTestEntity, entityConfiguration);

            TestData testData = InspectorUtils.CreateFromAttributeTable <TestData>(
                this.testGame.EntityManager, InspectorType.GetInspectorType(typeof(TestData)), attributeTable);

            Assert.AreNotEqual(testData.TestEntity, 0);
            Assert.AreNotEqual(testData.TestEntity, -1);

            // Check entity.
            TestComponent testComponent = this.testGame.EntityManager.GetComponent <TestComponent>(testData.TestEntity);

            Assert.NotNull(testComponent);
            Assert.AreEqual(testComponent.TestString, TestValueString);
        }
コード例 #6
0
        /// <summary>
        ///   Adds inspectors for the components of the specified blueprint and its parents.
        /// </summary>
        /// <param name="viewModel">Blueprint to add component inspectors for.</param>
        /// <param name="panel">Panel to add inspectors to.</param>
        /// <param name="getPropertyValue">Callback to get current value for a property.</param>
        /// <param name="onValueChanged">Callback to invoke when a property value changed.</param>
        public void AddComponentInspectorsRecursively(
            BlueprintViewModel viewModel,
            Panel panel,
            GetPropertyValueDelegate getPropertyValue,
            InspectorControlValueChangedDelegate onValueChanged)
        {
            // Add inspectors for parent blueprints.
            if (viewModel.Parent != null)
            {
                this.AddComponentInspectorsRecursively(viewModel.Parent, panel, getPropertyValue, onValueChanged);
            }

            // Add inspectors for specified blueprint.
            foreach (var componentType in viewModel.AddedComponents)
            {
                // Get attributes.
                InspectorType componentInfo = InspectorComponentTable.Instance.GetInspectorType(componentType);
                if (componentInfo == null)
                {
                    continue;
                }

                this.AddInspectorControls(componentInfo, panel, getPropertyValue, onValueChanged);
            }
        }
コード例 #7
0
    private void OnAreaPanelToggleChange(bool isOn)
    {
        outputPanel.SetPanel(inspectorOutput.transform);

        if (isOn)
        {
            inspectorType = InspectorType.Area;
            inspectorOutput.ActivateOutputPanel(inspectorType);

            ActivatePanels(isOn);
            areaInspectorPanel.UpdateAreasPtsInspectionDel();
            areaInspector.ShowAreaLines(isOn, areaInfos);

            // for (int i = 0; i < maxInspectionCount; ++i)
            // {
            //  areaInspector.UpdateAreaInspectorToggle(areaInfos[i], i == areaInspector.CurrAreaInspection);
            // }

            foreach (var layer in gridLayerController.mapLayers)
            {
                OnShowGrid(layer, true);
            }
        }
        lineInspector.ShowLinesAndControlPts(false, lineInfos);
    }
コード例 #8
0
 public static void Deinit(EntityManager entityManager, InspectorType inspectorType, object obj)
 {
     // Unset values for all properties.
     foreach (var inspectorProperty in inspectorType.Properties)
     {
         inspectorProperty.Deinit(entityManager, obj);
     }
 }
コード例 #9
0
        public void AddInspectorControls(
            InspectorType typeInfo,
            Panel panel,
            GetPropertyValueDelegate getPropertyValue,
            InspectorControlValueChangedDelegate onValueChanged,
            bool addNameLabel = true)
        {
            if (addNameLabel)
            {
                // Add label for component name.
                var componentName = typeInfo.Type.Name;
                componentName = componentName.Replace("Component", string.Empty);
                componentName = componentName.SplitByCapitalLetters();

                Label componentLabel = new Label
                {
                    Content    = componentName,
                    ToolTip    = typeInfo.Description,
                    FontWeight = FontWeights.Bold
                };
                panel.Children.Add(componentLabel);
            }

            // Add inspectors for component properties.
            foreach (var inspectorProperty in typeInfo.Properties)
            {
                // Get current value.
                bool inherited     = true;
                var  propertyValue = getPropertyValue != null
                                        ? getPropertyValue(inspectorProperty, out inherited)
                                        : inspectorProperty.Default;

                // Create control for inspector property.
                IInspectorControl propertyControl = this.CreateInspectorControlFor(
                    inspectorProperty, propertyValue, inherited);
                if (propertyControl == null)
                {
                    continue;
                }

                if (onValueChanged != null)
                {
                    // Subscribe for change of value.
                    propertyControl.ValueChanged += onValueChanged;
                }

                // Create wrapper.
                InspectorWithLabel inspectorWrapper = new InspectorWithLabel
                {
                    DataContext = ((FrameworkElement)propertyControl).DataContext,
                    Control     = propertyControl
                };

                // Add to panel.
                panel.Children.Add(inspectorWrapper);
            }
        }
コード例 #10
0
        private void TestAddingDefaultItemToEmptyList(InspectorType inspectorType, string propertyName)
        {
            InspectorPropertyAttribute testAttribute =
                inspectorType.Properties.First(property => property.Name == propertyName);

            // Create list.
            var list = testAttribute.GetEmptyList();

            list.Add(testAttribute.DefaultListItem);
        }
コード例 #11
0
 static void LockOrUnLockInspector()
 {
     if (InspectorAreas.Count > 0)
     {
         var  currentTabWindow = Panels.GetArrayElementAtIndex(currentTab).objectReferenceValue;
         bool result           = (bool)InspectorType.GetProperty("isLocked").GetValue(currentTabWindow, null) ? false:true;
         InspectorType.GetProperty("isLocked", BindingFlags.Instance | BindingFlags.Public).GetSetMethod().Invoke(currentTabWindow, new object[] { result });
         InspectorType.GetMethods().ToList().Find(d => d.ToString() == "Void Repaint()").Invoke(currentTabWindow, null);
     }
 }
コード例 #12
0
        /// <summary>
        /// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
        private void SetObjectToInspect(String resourcePath)
        {
            activeResourcePath = resourcePath;
            if (!ProjectLibrary.Exists(resourcePath))
            {
                return;
            }

            ResourceMeta meta         = ProjectLibrary.GetMeta(resourcePath);
            Type         resourceType = meta.Type;

            currentType = InspectorType.Resource;

            inspectorScrollArea = new GUIScrollArea();
            GUI.AddElement(inspectorScrollArea);
            inspectorLayout = inspectorScrollArea.Layout;

            GUIPanel titlePanel = inspectorLayout.AddPanel();

            titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT);

            GUILayoutY titleLayout = titlePanel.AddLayoutY();

            titleLayout.SetPosition(PADDING, PADDING);

            string name = Path.GetFileNameWithoutExtension(resourcePath);
            string type = resourceType.Name;

            LocString title      = new LocEdString(name + " (" + type + ")");
            GUILabel  titleLabel = new GUILabel(title);

            titleLayout.AddFlexibleSpace();
            GUILayoutX titleLabelLayout = titleLayout.AddLayoutX();

            titleLabelLayout.AddElement(titleLabel);
            titleLayout.AddFlexibleSpace();

            GUIPanel titleBgPanel = titlePanel.AddPanel(1);

            GUITexture titleBg = new GUITexture(null, EditorStylesInternal.InspectorTitleBg);

            titleBgPanel.AddElement(titleBg);

            inspectorLayout.AddSpace(COMPONENT_SPACING);

            inspectorResource       = new InspectorResource();
            inspectorResource.panel = inspectorLayout.AddPanel();

            var persistentProperties = persistentData.GetProperties(meta.UUID.ToString());

            inspectorResource.inspector = InspectorUtility.GetInspector(resourceType);
            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResourcePath, persistentProperties);

            inspectorLayout.AddFlexibleSpace();
        }
コード例 #13
0
        /// <summary>
        /// Destroys all inspector GUI elements.
        /// </summary>
        internal void Clear()
        {
            for (int i = 0; i < inspectorComponents.Count; i++)
            {
                inspectorComponents[i].foldout.Destroy();
                inspectorComponents[i].removeBtn.Destroy();
                inspectorComponents[i].inspector.Destroy();
            }

            inspectorComponents.Clear();

            if (inspectorResource != null)
            {
                inspectorResource.inspector.Destroy();
                inspectorResource = null;
            }

            if (inspectorScrollArea != null)
            {
                inspectorScrollArea.Destroy();
                inspectorScrollArea = null;
            }

            if (scrollAreaHighlight != null)
            {
                scrollAreaHighlight.Destroy();
                scrollAreaHighlight = null;
            }

            if (highlightPanel != null)
            {
                highlightPanel.Destroy();
                highlightPanel = null;
            }

            activeSO       = null;
            soNameInput    = null;
            soActiveToggle = null;
            soMobility     = null;
            soPrefabLayout = null;
            soHasPrefab    = false;
            soPosX         = null;
            soPosY         = null;
            soPosZ         = null;
            soRotX         = null;
            soRotY         = null;
            soRotZ         = null;
            soScaleX       = null;
            soScaleY       = null;
            soScaleZ       = null;
            dropAreas      = new Rect2I[0];

            activeResourcePath = null;
            currentType        = InspectorType.None;
        }
コード例 #14
0
 static void AddLockInspectorTab()
 {
     if (InspectorAreas.Count > 0)
     {
         var newInspector = ScriptableObject.CreateInstance(InspectorType) as EditorWindow;
         InspectorType.GetProperty("isLocked", BindingFlags.Instance | BindingFlags.Public).GetSetMethod().Invoke(newInspector, new object[] { true });
         FindDockAreaMethod("Void AddTab(UnityEditor.EditorWindow)").Invoke(InspectorArea, new object[] { newInspector });
         newInspector.Show();
         newInspector.Focus();
     }
 }
コード例 #15
0
        /// <summary>
        ///   Initializes the specified object via reflection with the specified property value.
        /// </summary>
        /// <param name="entityManager">Entity manager.</param>
        /// <param name="obj">Object to set property value for.</param>
        /// <param name="propertyValue">Property value to set.</param>
        public override void SetPropertyValue(EntityManager entityManager, object obj, object propertyValue)
        {
            IAttributeTable propertyAttributeTable = (IAttributeTable)propertyValue;

            propertyValue = Activator.CreateInstance(this.PropertyType);
            InspectorType propertyInspectorType = InspectorType.GetInspectorType(this.PropertyType);

            InspectorUtils.InitFromAttributeTable(entityManager, propertyInspectorType, propertyValue, propertyAttributeTable);

            base.SetPropertyValue(entityManager, obj, propertyValue);
        }
コード例 #16
0
        public static void SaveToAttributeTable(EntityManager entityManager, object obj, AttributeTable attributeTable)
        {
            InspectorType inspectorType = InspectorType.GetInspectorType(obj.GetType());

            if (inspectorType == null)
            {
                throw new ArgumentException("No inspector type for object " + obj.GetType());
            }

            SaveToAttributeTable(entityManager, inspectorType, obj, attributeTable);
        }
コード例 #17
0
        private void drawTopPanel()
        {
            Color was = GUI.backgroundColor;

            GUI.backgroundColor = Color.grey;
            GUILayout.BeginHorizontal(GUILayout.Height(topPanelHeight));

            //inspector
            if (selectedInspector == InspectorType.INSPECTOR)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.grey;
            }
            if (GUILayout.Button("Inspector", GUILayout.Width(100)))
            {
                selectedInspector = InspectorType.INSPECTOR;
            }

            //tasks
            if (selectedInspector == InspectorType.TASKS)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.grey;
            }
            if (GUILayout.Button("Tasks", GUILayout.Width(100)))
            {
                selectedInspector = InspectorType.TASKS;
                //get all tasks
                getAllTasks();
            }

            //parameters
            if (selectedInspector == InspectorType.PARAMETERS)
            {
                GUI.backgroundColor = Color.green;
            }
            else
            {
                GUI.backgroundColor = Color.grey;
            }
            if (GUILayout.Button("Parameters", GUILayout.Width(100)))
            {
                selectedInspector = InspectorType.PARAMETERS;
            }

            GUILayout.EndHorizontal();
            GUI.backgroundColor = was;
        }
コード例 #18
0
 static void AddLockInspectorWindowAtRight()
 {
     if (InspectorAreas.Count > 0)
     {
         var a            = new SerializedObject(InspectorArea).FindProperty("m_Panes").GetArrayElementAtIndex(0).objectReferenceValue as EditorWindow;
         var newInspector = ScriptableObject.CreateInstance(InspectorType) as EditorWindow;
         InspectorType.GetProperty("isLocked", BindingFlags.Instance | BindingFlags.Public).GetSetMethod().Invoke(newInspector, new object[] { true });
         newInspector.Show();
         PreviousNextSelection.DockEditorWindow(a, newInspector);
         newInspector.Focus();
     }
 }
コード例 #19
0
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            InspectorPropertyData  dataContext            = (InspectorPropertyData)this.DataContext;
            InspectorDataAttribute inspectorDataAttribute = (InspectorDataAttribute)dataContext.InspectorProperty;

            this.value            = (IAttributeTable)dataContext.Value;
            this.inspectorFactory = new InspectorFactory(dataContext.EditorContext, null);

            InspectorType typeInfo = InspectorType.GetInspectorType(inspectorDataAttribute.PropertyType);

            this.inspectorFactory.AddInspectorControls(typeInfo, this.Controls, this.GetPropertyValue, this.OnPropertyValueChanged, false);
        }
コード例 #20
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(null);
            }

            Type          componentType = (Type)value;
            InspectorType componentInfo = InspectorComponentTable.Instance.GetInspectorType(componentType);

            return(string.Format("{0}\n{1}", componentType.FullName, componentInfo.Description));
        }
コード例 #21
0
        /// <summary>
        /// Triggered when the user selects a new resource or a scene object, or deselects everything.
        /// </summary>
        /// <param name="objects">A set of new scene objects that were selected.</param>
        /// <param name="paths">A set of absolute resource paths that were selected.</param>
        private void OnSelectionChanged(SceneObject[] objects, string[] paths)
        {
            if (currentType == InspectorType.SceneObject && modifyState == InspectableState.NotModified)
            {
                UndoRedo.Global.PopCommand(undoCommandIdx);
            }

            Clear();
            modifyState = InspectableState.NotModified;

            if (objects.Length == 0 && paths.Length == 0)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea();
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("No object selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if ((objects.Length + paths.Length) > 1)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea();
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("Multiple objects selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if (objects.Length == 1)
            {
                if (objects[0] != null)
                {
                    UndoRedo.RecordSO(objects[0]);
                    undoCommandIdx = UndoRedo.Global.TopCommandId;

                    SetObjectToInspect(objects[0]);
                }
            }
            else if (paths.Length == 1)
            {
                SetObjectToInspect(paths[0]);
            }
        }
コード例 #22
0
        /// <summary>
        ///   Creates an object of the specified type and initializes it with
        ///   values from the passed attribute table, or default values of the
        ///   respective inspector properties, if no attribute value is present.
        /// </summary>
        /// <typeparam name="T">Type of the object to create.</typeparam>
        /// <param name="entityManager">
        ///   Entity manager to use for initializing the object, e.g. for creating entities from entity
        ///   configuration attributes.
        /// </param>
        /// <param name="inspectorType">Inspector data of the type of the object to create.</param>
        /// <param name="attributeTable">Attribute table to initialize the object with.</param>
        /// <returns>Initialized new object of the specified type.</returns>
        public static T CreateFromAttributeTable <T>(
            EntityManager entityManager,
            InspectorType inspectorType,
            IAttributeTable attributeTable) where T : class
        {
            // Create object.
            T obj = (T)Activator.CreateInstance(inspectorType.Type);

            // Init object.
            InitFromAttributeTable(entityManager, inspectorType, obj, attributeTable);

            return(obj);
        }
コード例 #23
0
        private void RemoveAttributeViewModels(Type componentType)
        {
            InspectorType componentInfo = InspectorComponentTable.Instance.GetInspectorType(componentType);

            var viewModelsToRemove =
                this.blueprintAttributeViewModels.Where(
                    viewModel => componentInfo.Properties.Any(property => property.Name.Equals(viewModel.Key))).ToList();

            foreach (var viewModelToRemove in viewModelsToRemove)
            {
                this.blueprintAttributeViewModels.Remove(viewModelToRemove);
            }
        }
コード例 #24
0
 private static void SaveToAttributeTable(
     EntityManager entityManager,
     InspectorType inspectorType,
     object obj,
     AttributeTable attributeTable)
 {
     // Set values for all properties.
     foreach (var inspectorProperty in inspectorType.Properties)
     {
         // Get value from object.
         object propertyValue = inspectorProperty.GetPropertyValue(entityManager, obj);
         attributeTable.SetValue(inspectorProperty.Name, propertyValue);
     }
 }
コード例 #25
0
        /// <summary>
        ///   Initializes an object by getting its inspector properties via reflection and
        ///   look them up in the specified attribute table.
        /// </summary>
        /// <param name="entityManager">
        ///   Entity manager to use for initializing the object, e.g. for creating entities from entity
        ///   configuration attributes.
        /// </param>
        /// <param name="obj">Object to initialize.</param>
        /// <param name="attributeTable">Attribute table to initialize from.</param>
        public static void InitFromAttributeTable(
            EntityManager entityManager,
            object obj,
            IAttributeTable attributeTable)
        {
            InspectorType inspectorType = InspectorType.GetInspectorType(obj.GetType());

            if (inspectorType == null)
            {
                return;
            }

            InitFromAttributeTable(entityManager, inspectorType, obj, attributeTable);
        }
コード例 #26
0
        private void DrawInspector(InspectorType inspectorType, IAttributeTable configuration, InspectorTypeTable inspectorTypeTable, IBlueprintManager blueprintManager)
        {
            foreach (var inspectorProperty in inspectorType.Properties)
            {
                // Get current value.
                object currentValue = configuration.GetValueOrDefault(inspectorProperty.Name, inspectorProperty.Default);
                object newValue     = EditorGUIUtils.LogicInspectorPropertyField(inspectorProperty, currentValue, inspectorTypeTable, blueprintManager);

                // Set new value if changed.
                if (!Equals(newValue, currentValue))
                {
                    configuration.SetValue(inspectorProperty.Name, newValue);
                }
            }
        }
コード例 #27
0
        /// <summary>
        ///   Initializes an object by getting its inspector properties from the specified inspector type
        ///   and look them up in the specified attribute table.
        /// </summary>
        /// <param name="entityManager">
        ///   Entity manager to use for initializing the object, e.g. for creating entities from entity
        ///   configuration attributes.
        /// </param>
        /// <param name="inspectorType">Contains information about the properties of the object.</param>
        /// <param name="obj">Object to initialize.</param>
        /// <param name="attributeTable">Attribute table to initialize from.</param>
        public static void InitFromAttributeTable(
            EntityManager entityManager,
            InspectorType inspectorType,
            object obj,
            IAttributeTable attributeTable)
        {
            // Set values for all properties.
            foreach (var inspectorProperty in inspectorType.Properties)
            {
                // Get value from attribute table or default.
                object propertyValue = attributeTable != null
                    ? attributeTable.GetValueOrDefault(inspectorProperty.Name, inspectorProperty.Default)
                    : inspectorProperty.Default;

                inspectorProperty.SetPropertyValue(entityManager, obj, propertyValue);
            }
        }
コード例 #28
0
        /// <summary>
        /// Triggered when the user selects a new resource or a scene object, or deselects everything.
        /// </summary>
        /// <param name="objects">A set of new scene objects that were selected.</param>
        /// <param name="paths">A set of absolute resource paths that were selected.</param>
        private void OnSelectionChanged(SceneObject[] objects, string[] paths)
        {
            Clear();
            modifyState = InspectableState.NotModified;

            if (objects.Length == 0 && paths.Length == 0)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("No object selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if ((objects.Length + paths.Length) > 1)
            {
                currentType         = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("Multiple objects selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if (objects.Length == 1)
            {
                if (objects[0] != null)
                {
                    SetObjectToInspect(objects[0]);
                }
            }
            else if (paths.Length == 1)
            {
                SetObjectToInspect(paths[0]);
            }
        }
コード例 #29
0
ファイル: InspectorTool.cs プロジェクト: gicait/ur-scape
    private void OnAreaPanelToggleChange(bool isOn)
    {
        outputPanel.SetPanel(inspectorOutput.transform);

        if (isOn)
        {
            inspectorType = InspectorType.Area;
            inspectorOutput.ActivateEntryInfo(inspectorType);

            ActivatePanels(isOn);
            areaInspector.ShowAreaLines(isOn, areaInfos);

            for (int i = 0; i < maxInspectionCount; ++i)
            {
                areaInspector.UpdateAreaInspectorToggle(areaInfos[i], i == areaInspector.CurrAreaInspection);
            }
        }
    }
コード例 #30
0
        private void AddAttributeViewModels(Type componentType)
        {
            InspectorType componentInfo = InspectorComponentTable.Instance.GetInspectorType(componentType);

            foreach (var property in componentInfo.Properties)
            {
                object value;
                this.Blueprint.TryGetValue(property.Name, out value);

                var viewModel = new BlueprintAttributeViewModel(value);
                viewModel.Blueprint    = this;
                viewModel.DefaultValue = property.Default;
                viewModel.Key          = property.Name;
                viewModel.Root         = this.Root;

                this.blueprintAttributeViewModels.Add(viewModel);
            }
        }
コード例 #31
0
 public NodeProperty(InspectorType inspectorType)
     : base(inspectorType)
 {
 }
コード例 #32
0
ファイル: InspectorWindow.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Destroys all inspector GUI elements.
        /// </summary>
        internal void Clear()
        {
            for (int i = 0; i < inspectorComponents.Count; i++)
            {
                inspectorComponents[i].foldout.Destroy();
                inspectorComponents[i].removeBtn.Destroy();
                inspectorComponents[i].inspector.Destroy();
            }

            inspectorComponents.Clear();

            if (inspectorResource != null)
            {
                inspectorResource.inspector.Destroy();
                inspectorResource = null;
            }

            if (inspectorScrollArea != null)
            {
                inspectorScrollArea.Destroy();
                inspectorScrollArea = null;
            }

            if (scrollAreaHighlight != null)
            {
                scrollAreaHighlight.Destroy();
                scrollAreaHighlight = null;
            }

            if (highlightPanel != null)
            {
                highlightPanel.Destroy();
                highlightPanel = null;
            }

            activeSO = null;
            soNameInput = null;
            soActiveToggle = null;
            soPrefabLayout = null;
            soHasPrefab = false;
            soPosX = null;
            soPosY = null;
            soPosZ = null;
            soRotX = null;
            soRotY = null;
            soRotZ = null;
            soScaleX = null;
            soScaleY = null;
            soScaleZ = null;
            dropAreas = new Rect2I[0];

            activeResource = null;
            currentType = InspectorType.None;
        }
コード例 #33
0
 public InspectorProperty(InspectorType inspectorType)
 {
     InspectorType = inspectorType;
 }
コード例 #34
0
 public InspectorProperty(string tip, InspectorType inspectorType)
 {
     InspectorType = inspectorType;
     InspectorTip = tip;
 }        
コード例 #35
0
ファイル: InspectorWindow.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Sets a scene object whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="so">Scene object to inspect.</param>
        private void SetObjectToInspect(SceneObject so)
        {
            if (so == null)
                return;

            currentType = InspectorType.SceneObject;
            activeSO = so;

            inspectorScrollArea = new GUIScrollArea();
            scrollAreaHighlight = new GUITexture(Builtin.WhiteTexture);
            scrollAreaHighlight.SetTint(HIGHLIGHT_COLOR);
            scrollAreaHighlight.Active = false;

            GUI.AddElement(inspectorScrollArea);
            GUIPanel inspectorPanel = inspectorScrollArea.Layout.AddPanel();
            inspectorLayout = inspectorPanel.AddLayoutY();
            highlightPanel = inspectorPanel.AddPanel(-1);
            highlightPanel.AddElement(scrollAreaHighlight);

            // SceneObject fields
            CreateSceneObjectFields();
            RefreshSceneObjectFields(true);

            // Components
            Component[] allComponents = so.GetComponents();
            for (int i = 0; i < allComponents.Length; i++)
            {
                inspectorLayout.AddSpace(COMPONENT_SPACING);

                InspectorComponent data = new InspectorComponent();
                data.instanceId = allComponents[i].InstanceId;

                data.foldout = new GUIToggle(allComponents[i].GetType().Name, EditorStyles.Foldout);
                data.removeBtn = new GUIButton(new GUIContent(EditorBuiltin.XBtnIcon), GUIOption.FixedWidth(30));

                data.title = inspectorLayout.AddLayoutX();
                data.title.AddElement(data.foldout);
                data.title.AddElement(data.removeBtn);
                data.panel = inspectorLayout.AddPanel();

                var persistentProperties = persistentData.GetProperties(allComponents[i].InstanceId);

                data.inspector = InspectorUtility.GetInspector(allComponents[i].GetType());
                data.inspector.Initialize(data.panel, allComponents[i], persistentProperties);

                bool isExpanded = data.inspector.Persistent.GetBool(data.instanceId + "_Expanded", true);
                data.foldout.Value = isExpanded;

                if (!isExpanded)
                    data.inspector.SetVisible(false);

                Type curComponentType = allComponents[i].GetType();
                data.foldout.OnToggled += (bool expanded) => OnComponentFoldoutToggled(data, expanded);
                data.removeBtn.OnClick += () => OnComponentRemoveClicked(curComponentType);

                inspectorComponents.Add(data);
            }

            inspectorLayout.AddFlexibleSpace();

            UpdateDropAreas();
        }
コード例 #36
0
ファイル: InspectorWindow.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Triggered when the user selects a new resource or a scene object, or deselects everything.
        /// </summary>
        /// <param name="objects">A set of new scene objects that were selected.</param>
        /// <param name="paths">A set of absolute resource paths that were selected.</param>
        private void OnSelectionChanged(SceneObject[] objects, string[] paths)
        {
            if (currentType == InspectorType.SceneObject && modifyState == InspectableState.NotModified)
                UndoRedo.PopCommand(undoCommandIdx);

            Clear();
            modifyState = InspectableState.NotModified;

            if (objects.Length == 0 && paths.Length == 0)
            {
                currentType = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea();
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("No object selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if ((objects.Length + paths.Length) > 1)
            {
                currentType = InspectorType.None;
                inspectorScrollArea = new GUIScrollArea();
                GUI.AddElement(inspectorScrollArea);
                inspectorLayout = inspectorScrollArea.Layout;

                inspectorLayout.AddFlexibleSpace();
                GUILayoutX layoutMsg = inspectorLayout.AddLayoutX();
                layoutMsg.AddFlexibleSpace();
                layoutMsg.AddElement(new GUILabel(new LocEdString("Multiple objects selected")));
                layoutMsg.AddFlexibleSpace();
                inspectorLayout.AddFlexibleSpace();
            }
            else if (objects.Length == 1)
            {
                if (objects[0] != null)
                {
                    UndoRedo.RecordSO(objects[0]);
                    undoCommandIdx = UndoRedo.TopCommandId;

                    SetObjectToInspect(objects[0]);
                }
            }
            else if (paths.Length == 1)
            {
                SetObjectToInspect(paths[0]);
            }
        }
コード例 #37
0
ファイル: InspectorWindow.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Sets a resource whose GUI is to be displayed in the inspector. Clears any previous contents of the window.
        /// </summary>
        /// <param name="resourcePath">Resource path relative to the project of the resource to inspect.</param>
        private void SetObjectToInspect(String resourcePath)
        {
            activeResource = ProjectLibrary.Load<Resource>(resourcePath);

            if (activeResource == null)
                return;

            currentType = InspectorType.Resource;

            inspectorScrollArea = new GUIScrollArea();
            GUI.AddElement(inspectorScrollArea);
            inspectorLayout = inspectorScrollArea.Layout;

            GUIPanel titlePanel = inspectorLayout.AddPanel();
            titlePanel.SetHeight(RESOURCE_TITLE_HEIGHT);

            GUILayoutY titleLayout = titlePanel.AddLayoutY();
            titleLayout.SetPosition(PADDING, PADDING);

            string name = Path.GetFileNameWithoutExtension(resourcePath);
            string type = activeResource.GetType().Name;

            LocString title = new LocEdString(name + " (" + type + ")");
            GUILabel titleLabel = new GUILabel(title);

            titleLayout.AddFlexibleSpace();
            GUILayoutX titleLabelLayout = titleLayout.AddLayoutX();
            titleLabelLayout.AddElement(titleLabel);
            titleLayout.AddFlexibleSpace();

            GUIPanel titleBgPanel = titlePanel.AddPanel(1);

            GUITexture titleBg = new GUITexture(null, EditorStyles.InspectorTitleBg);
            titleBgPanel.AddElement(titleBg);

            inspectorLayout.AddSpace(COMPONENT_SPACING);

            inspectorResource = new InspectorResource();
            inspectorResource.panel = inspectorLayout.AddPanel();

            var persistentProperties = persistentData.GetProperties(activeResource.UUID);

            inspectorResource.inspector = InspectorUtility.GetInspector(activeResource.GetType());
            inspectorResource.inspector.Initialize(inspectorResource.panel, activeResource, persistentProperties);

            inspectorLayout.AddFlexibleSpace();
        }