コード例 #1
0
        public static void AddHorizontalColoredTape(MenuCommand menuCommand)
        {
            GameObject coloredTape = SpringGUIDefaultControls.CreataHorizontalColoredTape(GetStandardResources());

            PlaceUIElementRoot(coloredTape, menuCommand);
            coloredTape.transform.localPosition = Vector3.zero;
            ColoredTape tape = coloredTape.GetComponent <ColoredTape>();

            tape.TapeDirection = ColoredTape.E_DrawDirection.Horizontal;
        }
コード例 #2
0
ファイル: ColorPicker.cs プロジェクト: zjwmyl/UnityCodes
        protected override void Start()
        {
            m_transform     = this.transform;
            m_mainColorTape = m_transform.FindChild("MainColor").GetComponent <MainColorTape>();

            #region  RGBA ColoredTape RGBA组件获取与事件监听
            var RGBA = m_transform.FindChild("RGBA");

            m_rText   = RGBA.transform.FindChild("R/Text").GetComponent <Text>();
            m_rValue  = RGBA.FindChild("R/Value").GetComponent <InputField>();
            m_rSlider = RGBA.FindChild("R/Slider").GetComponent <Slider>();
            m_rSlider.onValueChanged.AddListener(OnRedSliderChanged);
            m_rColoredTape = m_rSlider.transform.FindChild("ColoredTape").GetComponent <ColoredTape>();
            m_rValue.onValueChanged.AddListener(SetColorbyR);

            m_gText   = RGBA.transform.FindChild("G/Text").GetComponent <Text>();
            m_gValue  = RGBA.FindChild("G/Value").GetComponent <InputField>();
            m_gSlider = RGBA.FindChild("G/Slider").GetComponent <Slider>();
            m_gSlider.onValueChanged.AddListener(OnGreenSliderChanged);
            m_gColoredTape = m_gSlider.transform.FindChild("ColoredTape").GetComponent <ColoredTape>();
            m_gValue.onValueChanged.AddListener(SetColorbyG);

            m_bText   = RGBA.transform.FindChild("B/Text").GetComponent <Text>();
            m_bValue  = RGBA.FindChild("B/Value").GetComponent <InputField>();
            m_bSlider = RGBA.FindChild("B/Slider").GetComponent <Slider>();
            m_bSlider.onValueChanged.AddListener(OnBlueSliderChanged);
            m_bColoredTape = m_bSlider.transform.FindChild("ColoredTape").GetComponent <ColoredTape>();
            m_bValue.onValueChanged.AddListener(SetColorbyB);

            m_aText   = RGBA.transform.FindChild("A/Text").GetComponent <Text>();
            m_aValue  = RGBA.FindChild("A/Value").GetComponent <InputField>();
            m_aSlider = RGBA.FindChild("A/Slider").GetComponent <Slider>();
            m_aSlider.onValueChanged.AddListener(OnAlphaSliderChanged);
            m_aColoredTape = m_aSlider.transform.FindChild("ColoredTape").GetComponent <ColoredTape>();
            m_aValue.onValueChanged.AddListener(SetColorbyA);
            #endregion

            m_transform.FindChild("ColorSucker").GetComponent <Button>().onClick.AddListener(() => { WorkState = E_WorkState.Sucker; });
            m_transform.FindChild("PaletteModeButton").GetComponent <Button>().onClick.AddListener(ChangePaletteMode);
            //m_transform.FindChild("ColorModeButton").GetComponent<Button>().onClick.AddListener(ChangeColorMode);

            // Suck Color
            m_suckScreen  = m_transform.FindChild("SuckScreen");
            m_screenImage = m_suckScreen.FindChild("Texture").GetComponent <Image>();
            m_imageMesh   = m_suckScreen.FindChild("Mesh").GetComponent <ImageMesh>();

            // 调色板
            m_colorPalette = m_transform.FindChild("ColorPalette");
            //m_colorPaletteScript = m_colorPalette.GetComponent<ColorPalette>();
            m_nonius        = m_colorPalette.FindChild("ColorNonius");
            m_firstLayerCT  = m_colorPalette.FindChild("FirstLayerColoredTape").GetComponent <ColoredTape>();
            m_secondLayerCT = m_colorPalette.FindChild("SecondLayerColoredTape").GetComponent <ColoredTape>();
            m_multiCT       = m_colorPalette.FindChild("MultiColoredTape").GetComponent <MultiColoredTape>();
            m_leftText      = m_colorPalette.FindChild("LeftText").GetComponent <Text>();
            m_bottomText    = m_colorPalette.FindChild("BottomText").GetComponent <Text>();
            m_rightText     = m_colorPalette.FindChild("RightText").GetComponent <Text>();

            // 垂直滑动条
            m_coloredPate      = m_transform.FindChild("ColoredTapeSlider");
            m_verticalCTSlider = m_coloredPate.GetComponent <Slider>();
            m_verticalFirstCT  = m_coloredPate.FindChild("FirstLayerColoredTape").GetComponent <ColoredTape>();
            m_verticalCTSlider.onValueChanged.AddListener(verticalSliderChanged);

            // 预制颜色
            m_presetParent      = m_transform.FindChild("Presets/Colors");
            m_colorItemTamplate = m_presetParent.FindChild("ColorItemTamplate").gameObject;
            m_presetAddButton   = m_presetParent.FindChild("AddButton").GetComponent <Image>();
            m_presetParent.FindChild("AddButton").GetComponent <Button>().onClick.AddListener(AddPresetColor);

            // 初始化操作
            InitHexColor();
            Color = Color.white;
        }