当前位置: 首页>>代码示例>>C#>>正文


C# Control.AddChild方法代码示例

本文整理汇总了C#中Control.AddChild方法的典型用法代码示例。如果您正苦于以下问题:C# Control.AddChild方法的具体用法?C# Control.AddChild怎么用?C# Control.AddChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control.AddChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnInitialize

        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 );
        }
开发者ID:ChelseaLing,项目名称:UForms,代码行数:37,代码来源:Toolbox.cs

示例2: OnInitialize

    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;
    }
开发者ID:ChelseaLing,项目名称:UForms,代码行数:62,代码来源:DuplicateSpecial.cs

示例3: OnInitialize

    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 );
    }
开发者ID:ChelseaLing,项目名称:UForms,代码行数:93,代码来源:SystemInfoDisplay.cs


注:本文中的Control.AddChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。