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


C# GameObject.GetChild方法代码示例

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


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

示例1: PropertySlider

        /// <summary>
        /// 
        /// </summary>
        /// <param name="prefab"></param>
        public PropertySlider(WingProperty propRef, Color foreColour, Action<float> onChange)
        {
            propertyInstance = UnityEngine.Object.Instantiate(StaticWingGlobals.UI_PropertyPrefab);

            inputSlider = propertyInstance.GetChild("InputSlider").GetComponent<Slider>();
            inputSlider.fillRect.GetComponent<Image>().color = foreColour;

            propertyLabel = inputSlider.gameObject.GetChild("PropertyLabel").GetComponent<Text>();
            propertyLabel.text = propRef.name;
            input = inputSlider.gameObject.GetChild("UserInput").GetComponent<InputField>();

            Refresh(propRef);

            input.onValueChange.AddListener(TextValueChanged);
            inputSlider.onValueChanged.AddListener(SliderValueChanged);
            onValueChanged += onChange;
        }
开发者ID:RichardDastardly,项目名称:pWingsMerged,代码行数:21,代码来源:PropertySlider.cs

示例2: EditorWindow

        /// <summary>
        /// Constructor
        /// </summary>
        public EditorWindow()
        {
            // get references to all useful components
            canvas = UnityEngine.Object.Instantiate(StaticWingGlobals.UI_WindowPrefab.GetComponent<Canvas>());
            canvas.enabled = false;

            mainPanel = canvas.gameObject.GetChild("MainPanel");
            windowPosition = mainPanel.GetComponent<RectTransform>();
            GameObject headerPanel = mainPanel.GetChild("HeaderPanel");
            wingType = headerPanel.GetChild("WingType").GetComponent<Text>();
            lastModifiedProperty = headerPanel.GetChild("LastModifiedProperty").GetComponent<Text>();
            lastModifiedPropertyTooltip = headerPanel.GetChild("LastModifiedPropertyToolTip").GetComponent<Text>();
            closeButton = headerPanel.GetChild("CloseButton").GetComponent<Button>();

            // window position drag event
            EventTrigger.Entry entry = new EventTrigger.Entry();
            entry.eventID = EventTriggerType.Drag;
            entry.callback = new EventTrigger.TriggerEvent();
            entry.callback.AddListener((x) => windowDrag(x));
            mainPanel.GetComponent<EventTrigger>().triggers.Add(entry);

            // close button click hides the window
            closeButton.onClick.AddListener(closeWindow);
        }
开发者ID:RichardDastardly,项目名称:pWingsMerged,代码行数:27,代码来源:EditorWindow.cs

示例3: Start

        public void Start()
        {
            LoggingUtil.LogVerbose(this, "Start");

            // Don't run if not in career
            if (HighLogic.CurrentGame.Mode != Game.Modes.CAREER)
            {
                LoggingUtil.LogDebug(this, "Destroying TrackingStationUI - not in career mode.");
                Destroy(this);
                return;
            }

            // Get the last button in the list to use as a copy
            MapViewFiltering.FilterButton lastButton = MapViewFiltering.Instance.FilterButtons.Last();

            // Create our copies
            activeWaypointButton = UnityEngine.Object.Instantiate(lastButton.button.gameObject);
            activeWaypointButton.name = "Button Active Waypoints";
            offeredWaypointButton = UnityEngine.Object.Instantiate(lastButton.button.gameObject);
            offeredWaypointButton.name = "Button Offered Waypoints";
            activeOrbitButton = UnityEngine.Object.Instantiate(lastButton.button.gameObject);
            activeOrbitButton.name = "Button Active Orbits";
            offeredOrbitButton = UnityEngine.Object.Instantiate(lastButton.button.gameObject);
            offeredOrbitButton.name = "Button Offered Orbits";

            // Fix z coordinates
            activeWaypointButton.GetComponent<RectTransform>().SetLocalPositionZ(750);
            offeredWaypointButton.GetComponent<RectTransform>().SetLocalPositionZ(750);
            activeOrbitButton.GetComponent<RectTransform>().SetLocalPositionZ(750);
            offeredOrbitButton.GetComponent<RectTransform>().SetLocalPositionZ(750);

            // Set up the tool-tips
            activeWaypointButton.GetComponent<TooltipController_Text>().textString = "Toggle Active Waypoints";
            offeredWaypointButton.GetComponent<TooltipController_Text>().textString = "Toggle Offered Waypoints";
            activeOrbitButton.GetComponent<TooltipController_Text>().textString = "Toggle Active Orbits";
            offeredOrbitButton.GetComponent<TooltipController_Text>().textString = "Toggle Offered Orbits";

            // Setup the button
            TrackingStationObjectButton activeWaypointTSButton = activeWaypointButton.GetComponent<TrackingStationObjectButton>();
            TrackingStationObjectButton offeredWaypointTSButton = offeredWaypointButton.GetComponent<TrackingStationObjectButton>();
            TrackingStationObjectButton activeOrbitTSButton = activeOrbitButton.GetComponent<TrackingStationObjectButton>();
            TrackingStationObjectButton offeredOrbitTSButton = offeredOrbitButton.GetComponent<TrackingStationObjectButton>();

            // Setup handlers
            activeWaypointTSButton.OnClickLeft.AddListener(new UnityAction(ActiveWaypointButtonClick));
            activeWaypointTSButton.OnClickRight.AddListener(new UnityAction(ActiveWaypointButtonClick));
            offeredWaypointTSButton.OnClickLeft.AddListener(new UnityAction(OfferedWaypointButtonClick));
            offeredWaypointTSButton.OnClickRight.AddListener(new UnityAction(OfferedWaypointButtonClick));
            activeOrbitTSButton.OnClickLeft.AddListener(new UnityAction(ActiveOrbitButtonClick));
            activeOrbitTSButton.OnClickRight.AddListener(new UnityAction(ActiveOrbitButtonClick));
            offeredOrbitTSButton.OnClickLeft.AddListener(new UnityAction(OfferedOrbitButtonClick));
            offeredOrbitTSButton.OnClickRight.AddListener(new UnityAction(OfferedOrbitButtonClick));

            // Setup sprites
            activeWaypointTSButton.spriteTrue = activeWaypointEnabledSprite;
            activeWaypointTSButton.spriteFalse = activeWaypointDisabledSprite;
            offeredWaypointTSButton.spriteTrue = offeredWaypointEnabledSprite;
            offeredWaypointTSButton.spriteFalse = offeredWaypointDisabledSprite;
            activeOrbitTSButton.spriteTrue = activeOrbitEnabledSprite;
            activeOrbitTSButton.spriteFalse = activeOrbitDisabledSprite;
            offeredOrbitTSButton.spriteTrue = offeredOrbitEnabledSprite;
            offeredOrbitTSButton.spriteFalse = offeredOrbitDisabledSprite;

            // Set defaults
            ContractConfiguratorParameters parms = HighLogic.CurrentGame.Parameters.CustomParams<ContractConfiguratorParameters>();
            activeWaypointButton.GetComponent<TrackingStationObjectButton>().SetState(parms.DisplayActiveWaypoints);
            offeredWaypointButton.GetComponent<TrackingStationObjectButton>().SetState(parms.DisplayOfferedWaypoints);
            activeOrbitButton.GetComponent<TrackingStationObjectButton>().SetState(parms.DisplayActiveOrbits);
            offeredOrbitButton.GetComponent<TrackingStationObjectButton>().SetState(parms.DisplayOfferedOrbits);

            // Disable counts
            activeWaypointButton.GetChild("Count").SetActive(false);
            offeredWaypointButton.GetChild("Count").SetActive(false);
            activeOrbitButton.GetChild("Count").SetActive(false);
            offeredOrbitButton.GetChild("Count").SetActive(false);

            // Re-parent
            GameObject trackingFilters = lastButton.button.transform.parent.gameObject;
            RectTransform trackingFiltersRect = trackingFilters.GetComponent<RectTransform>();
            trackingFiltersRect.sizeDelta = new Vector2(trackingFiltersRect.sizeDelta.x + 44 * 2, trackingFiltersRect.sizeDelta.y);
            activeWaypointButton.transform.SetParent(trackingFilters.transform);
            offeredWaypointButton.transform.SetParent(trackingFilters.transform);
            activeOrbitButton.transform.SetParent(trackingFilters.transform);
            offeredOrbitButton.transform.SetParent(trackingFilters.transform);
            activeWaypointButton.SetActive(true);
            offeredWaypointButton.SetActive(true);
            activeOrbitButton.SetActive(true);
            offeredOrbitButton.SetActive(true);

            // Move the commNet button
            GameObject commNet = trackingFilters.transform.parent.gameObject.GetChild("CommNetVisualisation");
            if (commNet != null)
            {
                RectTransform r = commNet.GetComponent<RectTransform>();
                r.localPosition = new Vector3(r.localPosition.x + 132, r.localPosition.y);
            }

            LoggingUtil.LogVerbose(this, "Finished setup");
        }
开发者ID:Kerbas-ad-astra,项目名称:ContractConfigurator,代码行数:99,代码来源:TrackingStationUI.cs

示例4: EditorWindow

        /// <summary>
        /// Constructor
        /// </summary>
        public EditorWindow(string title)
        {
            // get references to all useful components
            go = Object.Instantiate(StaticWingGlobals.UI_WindowPrefab);
            go.transform.SetParent(KSP.UI.UIMasterController.Instance.appCanvas.transform, false);
            canvas = go.GetComponent<Canvas>();

            mainPanel = canvas.gameObject.GetChild("MainPanel");
            windowPosition = mainPanel.GetComponent<RectTransform>();
            GameObject headerPanel = mainPanel.GetChild("HeaderPanel");
            wingType = headerPanel.GetChild("WingType").GetComponent<Text>();
            lastModifiedProperty = headerPanel.GetChild("LastModifiedProperty").GetComponent<Text>();
            lastModifiedPropertyTooltip = headerPanel.GetChild("LastModifiedPropertyToolTip").GetComponent<Text>();
            closeButton = headerPanel.GetChild("CloseButton").GetComponent<Button>();

            // window position drag event
            EventTrigger.Entry dragEntry = new EventTrigger.Entry();
            dragEntry.eventID = EventTriggerType.Drag;
            dragEntry.callback = new EventTrigger.TriggerEvent();
            dragEntry.callback.AddListener((x) => windowDrag(x));
            mainPanel.GetComponent<EventTrigger>().triggers.Add(dragEntry);

            // close button click hides the window
            closeButton.onClick.AddListener(closeWindow);
            Visible = false;

            WindowTitle = title;
        }
开发者ID:Crzyrndm,项目名称:pWingsMerged,代码行数:31,代码来源:EditorWindow.cs


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