Esempio n. 1
0
        private void NewControl()
        {
            if (m_root != null)
            {
                if (!EditorUtility.DisplayDialog("Confirm New Control", "Are you sure you would like to create a new control? Current layout will be discarded!", "Ok", "Cancel"))
                {
                    return;
                }

                foreach (Control child in m_root.Children)
                {
                    RemoveChildControl(child);
                }

                m_workarea.RemoveChild(m_root);
                RemoveHierarchyEntry(m_root);
            }

            m_root = new Control();

            m_root.SetSize(100.0f, 100.0f);
            m_root.SetPosition(m_workarea.Size.x / 2.0f - 50.0f, m_workarea.Size.y / 2.0f - 50.0f);
            m_root.AddDecorator(new BackgroundColor(Color.gray));

            m_workarea.AddChild(m_root);
            SetSelectedControl(m_root);
            SetInspectorTarget(m_root);

            CreateHierarchyEntry(m_root, 0);
        }
Esempio n. 2
0
        public void AddChildDecorator(Type decoratorType)
        {
            if (m_root != null && m_selectedControl != null)
            {
                Decorator decorator = ( Decorator )Activator.CreateInstance(decoratorType);
                m_selectedControl.AddDecorator(decorator);

                UpdateHierarchyDecoratorData(m_selectedControl);
            }
        }
Esempio n. 3
0
        public FoldoutList( string title, float indentation, bool unfolded )
            : base()
        {
            m_indentationAmount = indentation;

            m_foldout = new Foldout( title, unfolded );
            m_foldout.SetWidth( 100.0f, MetricsUnits.Percentage );

            m_content = new Control();
            m_content.SetWidth( 100.0f, MetricsUnits.Percentage );
            m_content.AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
            m_content.AddDecorator( new FitContent( false, true, false, true ) );

            AddChild( m_foldout );
            AddChild( m_content );

            AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
            AddDecorator( new FitContent( false, true, false, true ) );

            m_foldout.ValueChange += FoldoutValueChange;
            SetFoldState( unfolded );
        }
Esempio n. 4
0
        public FoldoutList(string title, float indentation, bool unfolded)
            : base()
        {
            m_indentationAmount = indentation;

            m_foldout = new Foldout(title, unfolded);
            m_foldout.SetWidth(100.0f, MetricsUnits.Percentage);

            m_content = new Control();
            m_content.SetWidth(100.0f, MetricsUnits.Percentage);
            m_content.AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
            m_content.AddDecorator(new FitContent(false, true, false, true));

            AddChild(m_foldout);
            AddChild(m_content);

            AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
            AddDecorator(new FitContent(false, true, false, true));

            m_foldout.ValueChange += FoldoutValueChange;
            SetFoldState(unfolded);
        }
Esempio n. 5
0
        protected override void OnInitialize()
        {
            title = "Toolbox";

            m_buttonMapping = new Dictionary<Button, CachedControl>();
            m_controlsCache = new ToolboxControlCache();

            m_root = new Control();
            m_root.AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
            m_root.AddDecorator( new Scrollbars( true, false, true ) );
            m_root.SetSize( 100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage );

            // Create category foldouts, index them by name so we can assign our controls
            Dictionary< string, FoldoutList > foldouts = new Dictionary<string, FoldoutList>();

            foreach( string category in m_controlsCache.Categories )
            {
                FoldoutList foldout = new FoldoutList( category, 4.0f, true );
                foldout.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
                m_root.AddChild( foldout );

                foldouts.Add( category, foldout );
            }

            foreach( CachedControl c in m_controlsCache.Controls )
            {
                Button button = new Button( c.name );
                button.SetSize( 100.0f, CONTROL_DISPLAY_HEIGHT, Control.MetricsUnits.Percentage, Control.MetricsUnits.Pixel );
                button.Clicked += HandleControlButtonClick;

                m_buttonMapping.Add( button, c );

                foldouts[ c.category ].AddItem( button );
            }

            AddChild( m_root );
        }
Esempio n. 6
0
        protected override void OnInitialize()
        {
            title = "Toolbox";

            m_buttonMapping = new Dictionary <Button, CachedControl>();
            m_controlsCache = new ToolboxControlCache();

            m_root = new Control();
            m_root.AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
            m_root.AddDecorator(new Scrollbars(true, false, true));
            m_root.SetSize(100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage);

            // Create category foldouts, index them by name so we can assign our controls
            Dictionary <string, FoldoutList> foldouts = new Dictionary <string, FoldoutList>();

            foreach (string category in m_controlsCache.Categories)
            {
                FoldoutList foldout = new FoldoutList(category, 4.0f, true);
                foldout.SetWidth(100.0f, Control.MetricsUnits.Percentage);
                m_root.AddChild(foldout);

                foldouts.Add(category, foldout);
            }

            foreach (CachedControl c in m_controlsCache.Controls)
            {
                Button button = new Button(c.name);
                button.SetSize(100.0f, CONTROL_DISPLAY_HEIGHT, Control.MetricsUnits.Percentage, Control.MetricsUnits.Pixel);
                button.Clicked += HandleControlButtonClick;

                m_buttonMapping.Add(button, c);

                foldouts[c.category].AddItem(button);
            }

            AddChild(m_root);
        }
Esempio n. 7
0
        protected override void OnInitialize()
        {
            m_generator = new UFormsCodeGenerator();

            title = "Control Designer";

            m_menu = new DesignerTopMenu();
            m_menu.SetSize(100.0f, CONTROL_DISPLAY_HEIGHT, Control.MetricsUnits.Percentage, Control.MetricsUnits.Pixel);
            m_menu.MenuOptionSelected += HandleMenuOptionSelected;

            AddChild(m_menu);

            m_inspectorFields = new Dictionary <object, PropertyInfo>();
            m_hierarchyItems  = new Dictionary <Control, HierarchyItem>();

            m_inspector = new Control();
            m_inspector.SetPosition(position.width - INSPECTOR_WIDTH, CONTROL_DISPLAY_HEIGHT + TOP_MENU_SPACING);
            m_inspector.SetWidth(INSPECTOR_WIDTH);
            m_inspector.SetMargin(0.0f, 0.0f, SIDE_MARGIN, 0.0f);
            m_inspector.AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
            AddChild(m_inspector);

            m_hierarchy = new Control();
            m_hierarchy.SetPosition(0.0f, CONTROL_DISPLAY_HEIGHT + TOP_MENU_SPACING);
            m_hierarchy.SetWidth(HIERARCHY_WIDTH);
            m_hierarchy.SetMargin(SIDE_MARGIN, 0.0f, 0.0f, 0.0f);
            m_hierarchy.AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
            AddChild(m_hierarchy);

            m_workarea = new Control();
            m_workarea.SetPosition(m_viewportOffset);
            m_workarea.AddDecorator(new ClipContent());

            AddChild(m_workarea);

            m_resizeHandle = new Control();
            m_resizeHandle.SetSize(RESIZE_HANDLE_SIZE, RESIZE_HANDLE_SIZE);
            m_resizeHandle.AddDecorator(new BackgroundColor(Color.blue));
            m_resizeHandle.Visibility = Control.VisibilityMode.Hidden;

            AddChild(m_resizeHandle);

            SetSelectedControl(null);
            SetInspectorTarget(null);

            ShowToolbox();
        }
Esempio n. 8
0
    protected override void OnInitialize()
    {
        Vector2 winSize = new Vector3( 312.0f, 265.0f );
        maxSize = winSize;
        minSize = winSize;        

        autoRepaintOnSceneChange = true;

        m_root = new Control();
        m_root.SetSize( 100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage );
        m_root.AddDecorator( new StackContent() );

        AddChild( m_root );

        // Input object field
        m_original = new ObjectField( typeof( GameObject ), true, null, "Original" );
        m_original.SetHeight( 26.0f, Control.MetricsUnits.Pixel );
        m_original.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_original.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_original );

        // Rotation pivot point
        m_pivot = new Vector3Field( Vector3.zero, "Pivot:" );
        m_pivot.SetHeight( 40.0f, Control.MetricsUnits.Pixel );
        m_pivot.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_pivot.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_pivot );

        // Transform control
        m_transform = new TransformControl();
        m_transform.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_transform.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_transform );

        // Count field
        m_count = new IntField( 1, "Duplicate Count:" );
        m_count.SetHeight( 26.0f, Control.MetricsUnits.Pixel );
        m_count.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_count.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_count );

        // Space field
        m_space = new EnumDropdown( Space.World, "Space:" );
        m_space.SetHeight( 26.0f, Control.MetricsUnits.Pixel );
        m_space.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_space.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_root.AddChild( m_space );

        // Duplicate button
        m_duplicate = new Button( "Duplicate" );
        m_duplicate.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        m_duplicate.SetMargin( 5.0f, 5.0f, 5.0f, 5.0f );
        m_duplicate.Enabled = false;
        m_root.AddChild( m_duplicate );

        // Events
        m_original.ValueChange += m_original_ValueChange;
        m_count.ValueChange += m_count_ValueChange;
        m_duplicate.Clicked += m_duplicate_Clicked;

        SceneView.onSceneGUIDelegate += SceneViewGUI;
    }
Esempio n. 9
0
 public LayoutList(bool horizontal = true)
 {
     m_content = new Control();
     m_content.AddDecorator(new ClipContent(horizontal));
     AddChild(m_content);
 }
Esempio n. 10
0
    protected override void OnInitialize()
    {
        // Create a container control that will stack several foldouts with categorized system information
        // Control will fill 100% of our viewport, and will create vertical scrollbars if necesary
        Control sysinfo = new Control();

        sysinfo.AddDecorator(new StackContent(StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow));
        sysinfo.AddDecorator(new Scrollbars(true, false, true));
        sysinfo.SetSize(100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage);

        // Create a system information foldout list that will categorize our system information into general and feature categories
        // Don't forget to set width to 100% of the container width
        FoldoutList system = new FoldoutList("System", LIST_INDENTATION_PIXELS, true);

        system.SetWidth(100.0f, Control.MetricsUnits.Percentage);

        // Create a new foldout list to contain general system infromation and populate it with data
        // Child foldouts will stretch horizontally to fill the container
        FoldoutList systemGeneral = new FoldoutList("General", LIST_INDENTATION_PIXELS, true);

        systemGeneral.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        systemGeneral.AddItem(new LabelField(SystemInfo.deviceName, "Device Name:"));

        // Trying to access SystemInfo.deviceUniqueIdentifier from OnGUI seems to made Unity bleed internally, so we pre-cache it
        systemGeneral.AddItem(new LabelField(UDID, "UDID:"));

        systemGeneral.AddItem(new LabelField(SystemInfo.deviceModel, "Model:"));
        systemGeneral.AddItem(new LabelField(SystemInfo.deviceType.ToString(), "Type:"));
        systemGeneral.AddItem(new LabelField(SystemInfo.processorType, "Processor Type:"));
        systemGeneral.AddItem(new LabelField(SystemInfo.processorCount.ToString(), "Processor Count:"));
        systemGeneral.AddItem(new LabelField(string.Format("{0} MB", SystemInfo.systemMemorySize), "System Memory:"));
        systemGeneral.AddItem(new LabelField(SystemInfo.operatingSystem, "Operating System:"));

        // Second list for system features
        FoldoutList systemFeatures = new FoldoutList("Features", LIST_INDENTATION_PIXELS, true);

        systemFeatures.SetWidth(100.0f, Control.MetricsUnits.Percentage);

        systemFeatures.AddItem(new LabelField(SystemInfo.supportsVibration.ToString(), "Vibration:"));
        systemFeatures.AddItem(new LabelField(SystemInfo.supportsGyroscope.ToString(), "Gyroscope:"));
        systemFeatures.AddItem(new LabelField(SystemInfo.supportsAccelerometer.ToString(), "Accelerometer:"));
        systemFeatures.AddItem(new LabelField(SystemInfo.supportsLocationService.ToString(), "Location Service:"));

        // Add both category lists to the system list
        system.AddItem(systemGeneral);
        system.AddItem(systemFeatures);


        // Now recreate the previous structure for graphics information with 3 subcategories for general, features and texture support
        FoldoutList graphics = new FoldoutList("Graphics Device", LIST_INDENTATION_PIXELS, true);

        graphics.SetWidth(100.0f, Control.MetricsUnits.Percentage);

        FoldoutList graphicsGeneral = new FoldoutList("General", LIST_INDENTATION_PIXELS, true);

        graphicsGeneral.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsDeviceID.ToString(), "ID:"));
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsDeviceName, "Name:"));
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsDeviceVendorID.ToString(), "VendorID:"));
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsDeviceVendor, "Vendor:"));
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsDeviceVersion, "Version:"));
        graphicsGeneral.AddItem(new LabelField(string.Format("{0} MB", SystemInfo.graphicsMemorySize), "Memory:"));
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsPixelFillrate.ToString(), "Fillrate:"));
        graphicsGeneral.AddItem(new LabelField(SystemInfo.graphicsShaderLevel.ToString(), "Shader Level:"));

        FoldoutList graphicsFeatures = new FoldoutList("Features", LIST_INDENTATION_PIXELS, true);

        graphicsFeatures.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportedRenderTargetCount.ToString(), "Render Target Count:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supports3DTextures.ToString(), "3D Textures:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsComputeShaders.ToString(), "Compute Shaders:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsImageEffects.ToString(), "Image Effects:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsInstancing.ToString(), "Instancing:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsRenderTextures.ToString(), "Render Textures:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsRenderToCubemap.ToString(), "Render To Cubemap:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsShadows.ToString(), "Built-in Shdows:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsSparseTextures.ToString(), "Sparse Textures:"));
        graphicsFeatures.AddItem(new LabelField(SystemInfo.supportsStencil.ToString(), "Stencil:"));

        FoldoutList graphicsTextures = new FoldoutList("Texture Support", LIST_INDENTATION_PIXELS, true);

        graphicsTextures.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        graphicsTextures.AddItem(new LabelField(SystemInfo.npotSupport.ToString(), "Non Power of Two:"));

        foreach (RenderTextureFormat format in System.Enum.GetValues(typeof(RenderTextureFormat)))
        {
            graphicsTextures.AddItem(new LabelField(SystemInfo.SupportsRenderTextureFormat(format).ToString(), format.ToString()));
        }


        graphics.AddItem(graphicsGeneral);
        graphics.AddItem(graphicsFeatures);
        graphics.AddItem(graphicsTextures);

        // Add top level lists to our container element
        sysinfo.AddChild(system);
        sysinfo.AddChild(graphics);

        // Attach parent container
        AddChild(sysinfo);
    }
Esempio n. 11
0
    protected override void OnInitialize()
    {
        Vector2 winSize = new Vector3(312.0f, 265.0f);

        maxSize = winSize;
        minSize = winSize;

        autoRepaintOnSceneChange = true;

        m_root = new Control();
        m_root.SetSize(100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage);
        m_root.AddDecorator(new StackContent());

        AddChild(m_root);

        // Input object field
        m_original = new ObjectField(typeof(GameObject), true, null, "Original");
        m_original.SetHeight(26.0f, Control.MetricsUnits.Pixel);
        m_original.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        m_original.SetMargin(5.0f, 5.0f, 5.0f, 5.0f);
        m_root.AddChild(m_original);

        // Rotation pivot point
        m_pivot = new Vector3Field(Vector3.zero, "Pivot:");
        m_pivot.SetHeight(40.0f, Control.MetricsUnits.Pixel);
        m_pivot.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        m_pivot.SetMargin(5.0f, 5.0f, 5.0f, 5.0f);
        m_root.AddChild(m_pivot);

        // Transform control
        m_transform = new TransformControl();
        m_transform.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        m_transform.SetMargin(5.0f, 5.0f, 5.0f, 5.0f);
        m_root.AddChild(m_transform);

        // Count field
        m_count = new IntField(1, "Duplicate Count:");
        m_count.SetHeight(26.0f, Control.MetricsUnits.Pixel);
        m_count.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        m_count.SetMargin(5.0f, 5.0f, 5.0f, 5.0f);
        m_root.AddChild(m_count);

        // Space field
        m_space = new EnumDropdown(Space.World, "Space:");
        m_space.SetHeight(26.0f, Control.MetricsUnits.Pixel);
        m_space.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        m_space.SetMargin(5.0f, 5.0f, 5.0f, 5.0f);
        m_root.AddChild(m_space);

        // Duplicate button
        m_duplicate = new Button("Duplicate");
        m_duplicate.SetWidth(100.0f, Control.MetricsUnits.Percentage);
        m_duplicate.SetMargin(5.0f, 5.0f, 5.0f, 5.0f);
        m_duplicate.Enabled = false;
        m_root.AddChild(m_duplicate);

        // Events
        m_original.ValueChange += m_original_ValueChange;
        m_count.ValueChange    += m_count_ValueChange;
        m_duplicate.Clicked    += m_duplicate_Clicked;

        SceneView.onSceneGUIDelegate += SceneViewGUI;
    }
Esempio n. 12
0
    protected override void OnInitialize()
    {
        // Create a container control that will stack several foldouts with categorized system information
        // Control will fill 100% of our viewport, and will create vertical scrollbars if necesary
        Control sysinfo = new Control();
        sysinfo.AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
        sysinfo.AddDecorator( new Scrollbars( true, false, true ) );
        sysinfo.SetSize( 100.0f, 100.0f, Control.MetricsUnits.Percentage, Control.MetricsUnits.Percentage );

        // Create a system information foldout list that will categorize our system information into general and feature categories
        // Don't forget to set width to 100% of the container width
        FoldoutList system = new FoldoutList( "System", LIST_INDENTATION_PIXELS, true );
        system.SetWidth( 100.0f, Control.MetricsUnits.Percentage );

        // Create a new foldout list to contain general system infromation and populate it with data
        // Child foldouts will stretch horizontally to fill the container
        FoldoutList systemGeneral = new FoldoutList( "General", LIST_INDENTATION_PIXELS, true );
        systemGeneral.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        systemGeneral.AddItem( new LabelField( SystemInfo.deviceName, "Device Name:" ) );
        
        // Trying to access SystemInfo.deviceUniqueIdentifier from OnGUI seems to made Unity bleed internally, so we pre-cache it
        systemGeneral.AddItem( new LabelField( UDID, "UDID:" ) );
        
        systemGeneral.AddItem( new LabelField( SystemInfo.deviceModel, "Model:" ) );
        systemGeneral.AddItem( new LabelField( SystemInfo.deviceType.ToString(), "Type:" ) );
        systemGeneral.AddItem( new LabelField( SystemInfo.processorType, "Processor Type:" ) );
        systemGeneral.AddItem( new LabelField( SystemInfo.processorCount.ToString(), "Processor Count:" ) );
        systemGeneral.AddItem( new LabelField( string.Format( "{0} MB", SystemInfo.systemMemorySize ), "System Memory:" ) );
        systemGeneral.AddItem( new LabelField( SystemInfo.operatingSystem, "Operating System:" ) );

        // Second list for system features
        FoldoutList systemFeatures = new FoldoutList( "Features", LIST_INDENTATION_PIXELS, true );
        systemFeatures.SetWidth( 100.0f, Control.MetricsUnits.Percentage );

        systemFeatures.AddItem( new LabelField( SystemInfo.supportsVibration.ToString(), "Vibration:" ) );
        systemFeatures.AddItem( new LabelField( SystemInfo.supportsGyroscope.ToString(), "Gyroscope:" ) );
        systemFeatures.AddItem( new LabelField( SystemInfo.supportsAccelerometer.ToString(), "Accelerometer:" ) );
        systemFeatures.AddItem( new LabelField( SystemInfo.supportsLocationService.ToString(), "Location Service:" ) );

        // Add both category lists to the system list
        system.AddItem( systemGeneral );
        system.AddItem( systemFeatures );


        // Now recreate the previous structure for graphics information with 3 subcategories for general, features and texture support
        FoldoutList graphics = new FoldoutList( "Graphics Device", LIST_INDENTATION_PIXELS, true );
        graphics.SetWidth( 100.0f, Control.MetricsUnits.Percentage );

        FoldoutList graphicsGeneral = new FoldoutList( "General", LIST_INDENTATION_PIXELS, true );
        graphicsGeneral.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsDeviceID.ToString(), "ID:" ) );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsDeviceName, "Name:" ) );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsDeviceVendorID.ToString(), "VendorID:" ) );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsDeviceVendor, "Vendor:" ) );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsDeviceVersion, "Version:" ) );
        graphicsGeneral.AddItem( new LabelField( string.Format( "{0} MB", SystemInfo.graphicsMemorySize ), "Memory:" ) );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsPixelFillrate.ToString(), "Fillrate:" ) );
        graphicsGeneral.AddItem( new LabelField( SystemInfo.graphicsShaderLevel.ToString(), "Shader Level:" ) );

        FoldoutList graphicsFeatures = new FoldoutList( "Features", LIST_INDENTATION_PIXELS, true );
        graphicsFeatures.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportedRenderTargetCount.ToString(), "Render Target Count:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supports3DTextures.ToString(), "3D Textures:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsComputeShaders.ToString(), "Compute Shaders:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsImageEffects.ToString(), "Image Effects:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsInstancing.ToString(), "Instancing:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsRenderTextures.ToString(), "Render Textures:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsRenderToCubemap.ToString(), "Render To Cubemap:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsShadows.ToString(), "Built-in Shdows:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsSparseTextures.ToString(), "Sparse Textures:" ) );
        graphicsFeatures.AddItem( new LabelField( SystemInfo.supportsStencil.ToString(), "Stencil:" ) );

        FoldoutList graphicsTextures = new FoldoutList( "Texture Support", LIST_INDENTATION_PIXELS, true );
        graphicsTextures.SetWidth( 100.0f, Control.MetricsUnits.Percentage );
        graphicsTextures.AddItem( new LabelField( SystemInfo.npotSupport.ToString(), "Non Power of Two:" ) );

        foreach ( RenderTextureFormat format in System.Enum.GetValues( typeof( RenderTextureFormat ) ) )
        {
            graphicsTextures.AddItem( new LabelField( SystemInfo.SupportsRenderTextureFormat( format ).ToString(), format.ToString() ) );
        }


        graphics.AddItem( graphicsGeneral );
        graphics.AddItem( graphicsFeatures );
        graphics.AddItem( graphicsTextures );

        // Add top level lists to our container element
        sysinfo.AddChild( system );
        sysinfo.AddChild( graphics );

        // Attach parent container
        AddChild( sysinfo );
    }
Esempio n. 13
0
        private void NewControl()
        {
            if ( m_root != null )
            {
                if ( !EditorUtility.DisplayDialog( "Confirm New Control", "Are you sure you would like to create a new control? Current layout will be discarded!", "Ok", "Cancel" ) )
                {
                    return;
                }

                foreach( Control child in m_root.Children )
                {
                    RemoveChildControl( child );                    
                }

                m_workarea.RemoveChild( m_root );
                RemoveHierarchyEntry( m_root );
            }

            m_root = new Control();

            m_root.SetSize( 100.0f, 100.0f );
            m_root.SetPosition( m_workarea.Size.x / 2.0f - 50.0f, m_workarea.Size.y / 2.0f - 50.0f );
            m_root.AddDecorator( new BackgroundColor( Color.gray ) );

            m_workarea.AddChild( m_root );
            SetSelectedControl( m_root );
            SetInspectorTarget( m_root );

            CreateHierarchyEntry( m_root, 0 );
        }
Esempio n. 14
0
        protected override void OnInitialize()
        {
            m_generator = new UFormsCodeGenerator();

            title = "Control Designer";
            
            m_menu = new DesignerTopMenu();
            m_menu.SetSize( 100.0f, CONTROL_DISPLAY_HEIGHT, Control.MetricsUnits.Percentage, Control.MetricsUnits.Pixel );
            m_menu.MenuOptionSelected += HandleMenuOptionSelected;

            AddChild( m_menu );

            m_inspectorFields = new Dictionary<object, PropertyInfo>();
            m_hierarchyItems = new Dictionary<Control, HierarchyItem>();

            m_inspector = new Control();
            m_inspector.SetPosition( position.width - INSPECTOR_WIDTH , CONTROL_DISPLAY_HEIGHT + TOP_MENU_SPACING );
            m_inspector.SetWidth( INSPECTOR_WIDTH );
            m_inspector.SetMargin( 0.0f, 0.0f, SIDE_MARGIN, 0.0f );
            m_inspector.AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
            AddChild( m_inspector );

            m_hierarchy = new Control();
            m_hierarchy.SetPosition( 0.0f, CONTROL_DISPLAY_HEIGHT + TOP_MENU_SPACING );
            m_hierarchy.SetWidth( HIERARCHY_WIDTH );
            m_hierarchy.SetMargin( SIDE_MARGIN, 0.0f, 0.0f, 0.0f );
            m_hierarchy.AddDecorator( new StackContent( StackContent.StackMode.Vertical, StackContent.OverflowMode.Flow ) );
            AddChild( m_hierarchy );

            m_workarea = new Control();
            m_workarea.SetPosition( m_viewportOffset );
            m_workarea.AddDecorator( new ClipContent() );

            AddChild( m_workarea );

            m_resizeHandle = new Control();
            m_resizeHandle.SetSize( RESIZE_HANDLE_SIZE, RESIZE_HANDLE_SIZE );
            m_resizeHandle.AddDecorator( new BackgroundColor( Color.blue ) );
            m_resizeHandle.Visibility = Control.VisibilityMode.Hidden;

            AddChild( m_resizeHandle );

            SetSelectedControl( null );
            SetInspectorTarget( null );

            ShowToolbox();
        }