Exemple #1
0
        public override void Setup(AssetData listData, bool firstTime)
        {
            base.Setup(listData, firstTime);

            m_PreviewCoroutine        = null;
            m_VisibilityCoroutine     = null;
            m_AutoHidePreview         = false;
            icon.transform.localScale = Vector3.one;

            // First time setup
            if (!m_Setup)
            {
                // Cube material might change, so we always instance it
                MaterialUtils.GetMaterialClone(m_Cube);

                m_Handle.dragStarted += OnDragStarted;
                m_Handle.dragging    += OnDragging;
                m_Handle.dragging    += OnDraggingFeedForward;
                m_Handle.dragEnded   += OnDragEnded;

                m_Handle.hoverStarted += OnHoverStarted;
                m_Handle.hoverEnded   += OnHoverEnded;

                m_Handle.getDropObject = GetDropObject;

                AssetDropUtils.AssignmentDependencies.TryGetValue(data.type, out m_AssignmentDependencyTypes);

                m_Setup = true;
            }

            InstantiatePreview();

            m_Text.text = listData.name;
        }
Exemple #2
0
        void Start()
        {
            if (m_ToolType == null)
            {
                m_GradientButton.gameObject.SetActive(false);
            }

            tooltipAlignment = TextAlignment.Center;

            m_GradientButton.hoverEnter += OnBackgroundHoverEnter; // Display the foreground button actions
            m_GradientButton.hoverExit  += OnActionButtonHoverExit;
            m_GradientButton.click      += OnBackgroundButtonClick;

            m_FrameRenderer.SetBlendShapeWeight(1, 0f);
            m_CloseInsetMeshRenderer.SetBlendShapeWeight(0, 100f);
            m_CloseInsetMaskMeshRenderer.SetBlendShapeWeight(0, 100f);

            m_CloseButton.hoverEnter += OnBackgroundHoverEnter; // Display the foreground button actions
            m_CloseButton.hoverExit  += OnActionButtonHoverExit;
            m_CloseButton.click      += OnSecondaryButtonClicked;
            m_CloseButtonContainerCanvasGroup.alpha = 0f;

            // These materials have already been cloned when instantiating this button
            m_InsetMaterial      = m_InsetMeshRenderer.sharedMaterial;
            m_CloseInsetMaterial = m_CloseInsetMeshRenderer.sharedMaterial;
            // These materials have NOT been cloned when instantiating this button
            m_MaskMaterial            = MaterialUtils.GetMaterialClone(m_MaskRenderer);
            m_CloseButtonMaskMaterial = MaterialUtils.GetMaterialClone(m_CloseInsetMaskMeshRenderer);

            m_InsetMaterial.SetInt(k_MaterialStencilRefProperty, stencilRef);
            m_MaskMaterial.SetInt(k_MaterialStencilRefProperty, stencilRef);
            m_CloseInsetMaterial.SetInt(k_MaterialStencilRefProperty, stencilRef);
            m_CloseButtonMaskMaterial.SetInt(k_MaterialStencilRefProperty, stencilRef);
        }
Exemple #3
0
 void Awake()
 {
     m_ScrollLineRenderer.SetVertexCount(4);
     m_ScrollLineRenderer.useWorldSpace = true;
     m_ScrollLineRenderer.SetWidth(0f, 0f);
     m_HintLineMaterial = MaterialUtils.GetMaterialClone(m_MeshRenderer);
 }
        void Start()
        {
            if (!m_EditorWindowCapture)
            {
                m_EditorWindowCapture = GetComponent <EditorWindowCapture>();
            }

            if (!m_RawImage)
            {
                m_RawImage = GetComponent <RawImage>();
            }

            if (m_RawImage)
            {
                // Texture comes in flipped, so it's necessary to correct it
                var rect = m_RawImage.uvRect;
                rect.height      *= -1f;
                m_RawImage.uvRect = rect;
            }

            if (!m_RawImage && !m_Material)
            {
                var renderer = GetComponent <Renderer>();
                m_Material = MaterialUtils.GetMaterialClone(renderer);
            }

            if (m_Material)
            {
                // Texture comes in flipped, so it's necessary to correct it
                var scale = m_Material.mainTextureScale;
                scale.y *= -1f;
                m_Material.mainTextureScale = scale;
            }
        }
        protected override void Setup()
        {
            base.Setup();

            m_TextMaterial        = Instantiate(m_TextMaterial);
            m_ExpandArrowMaterial = Instantiate(m_ExpandArrowMaterial);

            m_BottomDropZoneMaterial    = MaterialUtils.GetMaterialClone(m_BottomDropZone.GetComponent <Renderer>());
            m_BottomDropZoneStartHeight = m_BottomDropZone.transform.localScale.z;
            m_TopDropZoneMaterial       = MaterialUtils.GetMaterialClone(m_TopDropZone.GetComponent <Renderer>());
            var color = m_TopDropZoneMaterial.color;

            m_DropZoneAlpha                = color.a;
            color.a                        = 0;
            m_TopDropZoneMaterial.color    = color;
            m_BottomDropZoneMaterial.color = color;

            var dropZones = new[] { m_BottomDropZone, m_TopDropZone };

            foreach (var dropZone in dropZones)
            {
                dropZone.canDrop           = CanDrop;
                dropZone.receiveDrop       = RecieveDrop;
                dropZone.dropHoverStarted += DropHoverStarted;
                dropZone.dropHoverEnded   += DropHoverEnded;
            }

            m_BottomDropZone.gameObject.SetActive(false);             // Don't block scroll interaction
        }
        public override void Setup(FolderData listData, bool firstTime = true)
        {
            base.Setup(listData, firstTime);

            if (firstTime)
            {
                // Cube material might change for hover state, so we always instance it
                m_CubeRenderer = m_Cube.GetComponent <Renderer>();
                m_NormalColor  = m_CubeRenderer.sharedMaterial.color;
                MaterialUtils.GetMaterialClone(m_CubeRenderer);

                m_ExpandArrow.pointerUp += ToggleExpanded;
                m_Cube.pointerDown      += SelectFolder;
                m_Cube.pointerUp        += ToggleExpanded;

                m_Cube.hoverStarted += OnHoverStarted;
                m_Cube.hoverEnded   += OnHoverEnded;
            }

            m_CubeTransform = m_Cube.transform;
            m_Text.text     = listData.name;

            m_ExpandArrow.gameObject.SetActive(listData.children != null);
            m_Hovering = false;
        }
Exemple #7
0
        public override void Setup(AssetData listData)
        {
            base.Setup(listData);

            m_PreviewCoroutine        = null;
            m_VisibilityCoroutine     = null;
            m_AutoHidePreview         = false;
            icon.transform.localScale = Vector3.one;

            // First time setup
            if (!m_Setup)
            {
                // Cube material might change, so we always instance it
                MaterialUtils.GetMaterialClone(m_Cube);

                m_Handle.dragStarted += OnDragStarted;
                m_Handle.dragging    += OnDragging;
                m_Handle.dragEnded   += OnDragEnded;

                m_Handle.hoverStarted += OnHoverStarted;
                m_Handle.hoverEnded   += OnHoverEnded;

                m_Handle.getDropObject = GetDropObject;

                m_Setup = true;
            }

            InstantiatePreview();

            m_Text.text = listData.name;
        }
Exemple #8
0
 void Awake()
 {
     m_TopHighlightMaterial = MaterialUtils.GetMaterialClone(m_TopHighlightRenderer);
     m_TopHighlightMaterial.SetColor(k_TopColorProperty, UnityBrandColorScheme.sessionGradient.a);
     m_TopHighlightMaterial.SetColor(k_BottomColorProperty, UnityBrandColorScheme.sessionGradient.b);
     m_TopHighlightMaterial.SetFloat(k_AlphaProperty, 0f); // hide the highlight initially
 }
        void Awake()
        {
            m_OriginalIconSprite                  = m_Icon.sprite;
            m_ButtonMaterial                      = MaterialUtils.GetMaterialClone(m_ButtonMeshRenderer);
            m_OriginalLocalScale                  = transform.localScale;
            m_OriginalIconLocalPosition           = m_IconContainer.localPosition;
            m_OriginalContentContainerLocalScale  = m_ContentContainer.localScale;
            m_HighlightContentContainerLocalScale = new Vector3(m_OriginalContentContainerLocalScale.x, m_OriginalContentContainerLocalScale.y, m_OriginalContentContainerLocalScale.z * m_HighlightZScaleMultiplier);
            m_IconHighlightedLocalPosition        = m_OriginalIconLocalPosition + Vector3.forward * m_IconHighlightedLocalZOffset;
            m_IconPressedLocalPosition            = m_OriginalIconLocalPosition + Vector3.back * m_IconHighlightedLocalZOffset;

            m_Icon.color = m_NormalContentColor;
#if INCLUDE_TEXT_MESH_PRO
            m_Text.color = m_NormalContentColor;

            // Clears/resets any non-sprite content(text) from being displayed if a sprite was set on this button
            if (m_OriginalIconSprite)
            {
                SetContent(m_OriginalIconSprite, m_AlternateIconSprite);
            }
            else if (!string.IsNullOrEmpty(m_Text.text))
            {
                SetContent(m_Text.text);
            }
#endif
        }
Exemple #10
0
        void SetupCustomButtonMaterials(Graphic[] graphics, MainMenuFace face)
        {
            const string topGradientProperty    = "_ColorTop";
            const string bottomGradientProperty = "_ColorBottom";
            Material     materialClone          = null;

            foreach (var graphic in graphics)
            {
                // Assign face gradient to custom buttons on a given face (Settings face: locomotion, snapping, etc)
                var material = graphic.material;
                if (material.HasProperty(topGradientProperty))
                {
                    if (materialClone == null)
                    {
                        // Only clone the material if a material with a matching property is found in this custom-button/sub-menu
                        materialClone = MaterialUtils.GetMaterialClone(graphic);
                        m_MaterialsToCleanup.Add(materialClone);
                        materialClone.SetColor(topGradientProperty, face.gradientPair.a);
                        if (materialClone.HasProperty(bottomGradientProperty))
                        {
                            materialClone.SetColor(bottomGradientProperty, face.gradientPair.b);
                        }
                    }

                    graphic.material = materialClone;
                }
            }
        }
Exemple #11
0
        public override void Setup(FolderData listData)
        {
            base.Setup(listData);

            // First time setup
            if (m_CubeRenderer == null)
            {
                // Cube material might change for hover state, so we always instance it
                m_CubeRenderer = m_Cube.GetComponent <Renderer>();
                m_NormalColor  = m_CubeRenderer.sharedMaterial.color;
                MaterialUtils.GetMaterialClone(m_CubeRenderer);

                m_ExpandArrow.dragEnded += ToggleExpanded;
                m_Cube.dragStarted      += SelectFolder;
                m_Cube.dragEnded        += ToggleExpanded;

                m_Cube.hoverStarted += OnHoverStarted;
                m_Cube.hoverEnded   += OnHoverEnded;
            }

            m_CubeTransform = m_Cube.transform;
            m_Text.text     = listData.name;

            // HACK: We need to kick the canvasRenderer to update the mesh properly
            m_Text.gameObject.SetActive(false);
            m_Text.gameObject.SetActive(true);

            m_ExpandArrow.gameObject.SetActive(listData.children != null);
            m_Hovering = false;
        }
Exemple #12
0
        private void Awake()
        {
            viewerScale                = 1;
            m_LineRenderer             = GetComponent <VRLineRenderer>();
            m_LineRendererMeshRenderer = m_LineRenderer.GetComponent <MeshRenderer>();
            m_BlinkMaterial            = MaterialUtils.GetMaterialClone(m_RoomScaleRenderer);

            foreach (var renderer in m_LocatorRoot.GetComponentsInChildren <Renderer>())
            {
                renderer.sharedMaterial = m_BlinkMaterial;
            }

            if (!m_ToolPoint)
            {
                m_ToolPoint = transform;
            }

            m_RoomScaleTransform               = m_RoomScaleRenderer.transform;
            m_RoomScaleTransform.parent        = m_LocatorRoot;
            m_RoomScaleTransform.localPosition = Vector3.zero;
            m_RoomScaleTransform.localRotation = Quaternion.identity;

            m_Transform = transform;

            m_LineRenderer.SetVertexCount(m_LineSegmentCount);
            m_LineRenderer.useWorldSpace = true;

            m_MotionSpheres = new Transform[m_MotionSphereCount];
            for (int i = 0; i < m_MotionSphereCount; i++)
            {
                var sphere = ((GameObject)Instantiate(m_MotionIndicatorSphere, m_ToolPoint.position, m_ToolPoint.rotation)).transform;
                m_MotionSpheres[i] = sphere;
                sphere.SetParent(m_Transform, false);
                sphere.name = "motion-sphere-" + i;
                sphere.gameObject.SetActive(false);

                var sphereRenderer = sphere.GetComponent <MeshRenderer>();
                if (m_MotionSpheresMaterial == null)                 // Only one material clone is needed
                {
                    m_MotionSpheresMaterial = MaterialUtils.GetMaterialClone(sphereRenderer);
                }

                sphereRenderer.sharedMaterial = m_MotionSpheresMaterial;
            }
            m_MotionSphereOriginalScale = m_MotionSpheres[0].localScale;
            m_CurveLengthEstimate       = 1.0f;
            m_MotionSphereOffset        = 0.0f;

            m_RingTransform = m_RingRenderer.transform;
            m_RingTransformOriginalScale = m_RingTransform.localScale;
            m_TubeTransform = m_TubeRenderer.transform;
            m_TubeTransformOriginalScale = m_TubeTransform.localScale;
            m_TubeTransformHiddenScale   = new Vector3(m_TubeTransform.localScale.x, 0.0001f, m_TubeTransform.localScale.z);

            ShowLine(false);

            showValidTargetIndicator = true;
        }
Exemple #13
0
        public override void Setup(HierarchyData data)
        {
            base.Setup(data);

            // First time setup
            if (cubeMaterial == null)
            {
                // Cube material might change for hover state, so we always instance it
                m_CubeRenderer = m_Cube.GetComponent <Renderer>();
                cubeMaterial   = MaterialUtils.GetMaterialClone(m_CubeRenderer);
                m_NormalColor  = cubeMaterial.color;

                m_LockRenderer       = m_Lock.GetComponent <Renderer>();
                m_Lock.hoverStarted += (bh, ed) => { m_HoveringLock = true; };
                m_Lock.hoverEnded   += (bh, ed) => { m_HoveringLock = false; };
                m_Lock.dragEnded    += ToggleLock;

                m_ExpandArrowRenderer    = m_ExpandArrow.GetComponent <Renderer>();
                m_ExpandArrow.dragEnded += ToggleExpanded;
                m_Cube.dragStarted      += OnDragStarted;
                m_Cube.dragging         += OnDragging;
                m_Cube.dragEnded        += OnDragEnded;

                m_Cube.hoverStarted += OnHoverStarted;
                m_Cube.hoverEnded   += OnHoverEnded;

                m_Cube.click += OnClick;

                m_Cube.getDropObject = GetDropObject;
                m_Cube.canDrop       = CanDrop;
                m_Cube.receiveDrop   = ReceiveDrop;

                var dropZoneRenderer = m_DropZone.GetComponent <Renderer>();
                dropZoneMaterial = MaterialUtils.GetMaterialClone(dropZoneRenderer);
                var color = dropZoneMaterial.color;
                m_DropZoneHighlightAlpha = color.a;
                color.a = 0;
                dropZoneMaterial.color = color;

                m_DropZone.dropHoverStarted += OnDropHoverStarted;
                m_DropZone.dropHoverEnded   += OnDropHoverEnded;

                m_DropZone.canDrop       = CanDrop;
                m_DropZone.receiveDrop   = ReceiveDrop;
                m_DropZone.getDropObject = GetDropObject;
            }

            m_CubeTransform     = m_Cube.transform;
            m_DropZoneTransform = m_DropZone.transform;
            m_Text.text         = data.name;

            // HACK: We need to kick the canvasRenderer to update the mesh properly
            m_Text.gameObject.SetActive(false);
            m_Text.gameObject.SetActive(true);

            hovering = false;
        }
Exemple #14
0
        void Awake()
        {
            m_RayMaterial            = MaterialUtils.GetMaterialClone(m_LineRenderer.GetComponent <MeshRenderer>());
            m_ConeTransform          = m_Cone.transform;
            m_OriginalConeLocalScale = m_ConeTransform.localScale;

            rayVisible  = true;
            coneVisible = true;
        }
Exemple #15
0
        void Start()
        {
            m_BackgroundMaterial = MaterialUtils.GetMaterialClone(m_Background);
            m_BackgroundMaterial.SetInt("_StencilRef", stencilRef);

            m_VisibilityButton.clicked += OnVisibilityButtonClicked;
            m_VisibilityButton.hovered += OnHovered;
            m_SummaryButton.clicked    += OnVisibilityButtonClicked;
            m_SummaryButton.hovered    += OnHovered;
        }
Exemple #16
0
        void Awake()
        {
            var targetMeshTransform = m_TargetMesh.transform;

            m_TargetMeshInitialLocalPosition = targetMeshTransform.localPosition;
            m_TargetMeshInitialScale         = targetMeshTransform.localScale;
            m_TargetMeshMaterial             = MaterialUtils.GetMaterialClone(m_TargetMesh.GetComponent <Renderer>());
            m_TargetMeshBaseColor            = m_TargetMeshMaterial.color;
            m_CanvasGroup = GetComponentInChildren <CanvasGroup>(true);
        }
Exemple #17
0
        void Awake()
        {
            m_OriginalLocalPosition = transform.localPosition;
            m_OriginalLocalScale    = transform.localScale;
            m_FrameMaterial         = MaterialUtils.GetMaterialClone(m_FrameRenderer);
            var frameMaterialColor = m_FrameMaterial.color;

            s_FrameOpaqueColor = new Color(frameMaterialColor.r, frameMaterialColor.g, frameMaterialColor.b, 1f);
            m_FrameMaterial.SetColor(k_MaterialColorProperty, s_FrameOpaqueColor);
            m_IconMaterial = MaterialUtils.GetMaterialClone(m_ButtonIcon);
            m_OriginalIconContainerLocalScale = m_IconContainer.localScale;
        }
Exemple #18
0
        private void Awake()
        {
            m_CanvasGroup.alpha               = 0f;
            m_CanvasGroup.interactable        = false;
            m_BorderOutlineMaterial           = MaterialUtils.GetMaterialClone(m_BorderOutline);
            m_BorderOutlineTransform          = m_BorderOutline.transform;
            m_BorderOutlineOriginalLocalScale = m_BorderOutlineTransform.localScale;
            m_FaceTitle.text    = "Not Set";
            m_TitleIconMaterial = MaterialUtils.GetMaterialClone(m_TitleIcon);

            SetGradientColors(k_EmptyGradient);
        }
Exemple #19
0
        void Start()
        {
            m_InitAltitude = transform.position.y;

            m_RingMat = MaterialUtils.GetMaterialClone(m_RingTransform.GetComponent <MeshRenderer>());
            m_OrigGradient.SetKeys(m_LineA.colorGradient.colorKeys, m_LineA.colorGradient.alphaKeys);
            m_CurrentGradient.SetKeys(m_LineA.colorGradient.colorKeys, m_LineA.colorGradient.alphaKeys);

            m_LineLength = m_LineA.GetPosition(1).y;
            m_LineOffset = m_LineA.GetPosition(0).y;

            m_AlphaKeys = new GradientAlphaKey[m_OrigGradient.alphaKeys.Length];
        }
Exemple #20
0
        void Awake()
        {
            localBounds         = ObjectUtils.GetBounds(transform);
            m_TitleIconMaterial = MaterialUtils.GetMaterialClone(m_TitleIcon);
            m_TitleIconMaterial.SetColor(k_TopGradientProperty, UnityBrandColorScheme.saturatedSessionGradient.a);
            m_TitleIconMaterial.SetColor(k_BottomGradientProperty, UnityBrandColorScheme.saturatedSessionGradient.b);

            foreach (var button in m_Buttons)
            {
                button.hovered += OnButtonHovered;
                button.clicked += OnButtonClicked;
            }
        }
Exemple #21
0
        void Awake()
        {
            m_CanvasGroup.alpha               = 0f;
            m_CanvasGroup.interactable        = false;
            m_BorderOutlineMaterial           = MaterialUtils.GetMaterialClone(m_BorderOutline);
            m_BorderOutlineTransform          = m_BorderOutline.transform;
            m_BorderOutlineOriginalLocalScale = m_BorderOutlineTransform.localScale;
            m_TitleIconMaterial               = MaterialUtils.GetMaterialClone(m_TitleIcon);

            m_OriginalLocalScale = transform.localScale;
            m_HiddenLocalScale   = new Vector3(0f, m_OriginalLocalScale.y * 0.5f, m_OriginalLocalScale.z);

            gradientPair = k_EmptyGradient;
        }
Exemple #22
0
        public override void Setup(PolyGridAsset listData)
        {
            base.Setup(listData);

            // First time setup
            if (!m_Setup)
            {
                m_IconScale = m_Icon.transform.localScale;

                m_ImportingDefaultColor = m_TextPanel.color;

                m_Handle.dragStarted += OnDragStarted;
                m_Handle.dragging    += OnDragging;
                m_Handle.dragEnded   += OnDragEnded;

                m_Handle.hoverStarted += OnHoverStarted;
                m_Handle.hoverEnded   += OnHoverEnded;

                m_IconMaterial = MaterialUtils.GetMaterialClone(m_Icon.GetComponent <Renderer>());

                m_Setup = true;
            }

            m_Hovered        = false;
            m_WasHovered     = false;
            m_HoverLerpStart = 1f;
            m_HoverLerp      = 1f;

            m_Importing           = false;
            m_WasImporting        = false;
            m_ImportingStartScale = m_IconScale.y;
            m_ImportingScale      = m_ImportingStartScale;

            m_ImportingStartColor = m_ImportingDefaultColor;
            m_ImportingColor      = m_ImportingStartColor;

            m_VisibilityCoroutine       = null;
            m_Icon.transform.localScale = m_IconScale;
            m_IconMaterial.mainTexture  = null;

            if (m_PreviewObjectTransform)
            {
                ObjectUtils.Destroy(m_PreviewObjectTransform.gameObject);
            }

            m_SetupTime = Time.time;
            UpdateRepresentation();
        }
Exemple #23
0
        IEnumerator Start()
        {
            const string kShaderBlur           = "_Blur";
            const string kShaderAlpha          = "_Alpha";
            const string kShaderVerticalOffset = "_VerticalOffset";
            const float  kTargetDuration       = 1.25f;

            m_TopFaceMaterial = MaterialUtils.GetMaterialClone(m_TopFaceContainer.GetComponentInChildren <MeshRenderer>());
            m_TopFaceMaterial.SetFloat("_Alpha", 1f);
            m_TopFaceMaterial.SetInt(k_MaterialStencilRef, stencilRef);

            m_FrontFaceMaterial = MaterialUtils.GetMaterialClone(m_FrameFrontFaceTransform.GetComponentInChildren <MeshRenderer>());
            m_FrontFaceMaterial.SetInt(k_MaterialStencilRef, stencilRef);

            var originalBlurAmount = m_TopFaceMaterial.GetFloat("_Blur");
            var currentBlurAmount  = 10f; // also the maximum blur amount
            var currentDuration    = 0f;
            var currentVelocity    = 0f;

            m_TopFaceMaterial.SetFloat(kShaderBlur, currentBlurAmount);
            m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 1f); // increase the blur sample offset to amplify the effect
            m_TopFaceMaterial.SetFloat(kShaderAlpha, 0.5f);        // set partially transparent

            while (currentDuration < kTargetDuration)
            {
                currentDuration  += Time.deltaTime;
                currentBlurAmount = MathUtilsExt.SmoothDamp(currentBlurAmount, originalBlurAmount, ref currentVelocity, kTargetDuration, Mathf.Infinity, Time.deltaTime);
                m_TopFaceMaterial.SetFloat(kShaderBlur, currentBlurAmount);

                var percentageComplete = currentDuration / kTargetDuration;
                m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 1 - percentageComplete);  // lerp back towards an offset of zero
                m_TopFaceMaterial.SetFloat(kShaderAlpha, percentageComplete * 0.5f + 0.5f); // lerp towards fully opaque from 50% transparent

                yield return(null);
            }

            m_TopFaceMaterial.SetFloat(kShaderBlur, originalBlurAmount);
            m_TopFaceMaterial.SetFloat(kShaderVerticalOffset, 0f);
            m_TopFaceMaterial.SetFloat(kShaderAlpha, 1f);

            yield return(null);
        }
Exemple #24
0
    void Awake()
    {
        m_SphereScale     = m_MotionIndicatorSphere.transform.localScale;
        m_VisualsMaterial = MaterialUtils.GetMaterialClone(m_MotionIndicatorSphere.GetComponent <Renderer>());

        m_Positions = new Vector3[m_MaxProjectileSteps];

        m_LineRenderer = GetComponent <VRLineRenderer>();
        m_LineRenderer.SetPositions(m_Positions, true);

        m_Spheres = new Transform[m_SphereCount];
        for (var i = 0; i < m_SphereCount; i++)
        {
            m_Spheres[i] = Instantiate(m_MotionIndicatorSphere, transform, false).transform;
        }

        foreach (var renderer in m_ArcLocator.GetComponentsInChildren <Renderer>(true))
        {
            renderer.sharedMaterial = m_VisualsMaterial;
        }
    }
Exemple #25
0
        public override void Setup(AssetData listData)
        {
            base.Setup(listData);

            m_PreviewCoroutine    = null;
            m_VisibilityCoroutine = null;

            // First time setup
            if (!m_Setup)
            {
                // Cube material might change, so we always instance it
                MaterialUtils.GetMaterialClone(m_Cube);

                m_Handle.dragStarted += OnDragStarted;
                m_Handle.dragging    += OnDragging;
                m_Handle.dragEnded   += OnDragEnded;

                m_Handle.hoverStarted += OnHoverStarted;
                m_Handle.hoverEnded   += OnHoverEnded;

                m_Handle.getDropObject = GetDropObject;

                m_Setup = true;
            }

            InstantiatePreview();

            icon.transform.localScale = Vector3.one;

            if (m_PreviewObjectTransform)
            {
                m_PreviewObjectTransform.localScale = Vector3.zero;
            }

            m_Text.text = listData.name;

            // HACK: We need to kick the canvasRenderer to update the mesh properly
            m_Text.gameObject.SetActive(false);
            m_Text.gameObject.SetActive(true);
        }
Exemple #26
0
        void Awake()
        {
            m_InsetMaterial              = MaterialUtils.GetMaterialClone(m_InsetMeshRenderer);
            m_IconMaterial               = MaterialUtils.GetMaterialClone(m_Icon);
            m_OriginalInsetGradientPair  = new GradientPair(m_InsetMaterial.GetColor(k_MaterialColorTopProperty), m_InsetMaterial.GetColor(k_MaterialColorBottomProperty));
            hiddenLocalRotation          = transform.localRotation;
            m_VisibleInsetLocalScale     = m_MenuInset.localScale;
            m_HighlightedInsetLocalScale = new Vector3(m_VisibleInsetLocalScale.x, m_VisibleInsetLocalScale.y * 1.2f, m_VisibleInsetLocalScale.z);
            m_VisibleInsetLocalScale     = new Vector3(m_VisibleInsetLocalScale.x, m_MenuInset.localScale.y * 0.35f, m_VisibleInsetLocalScale.z);
            m_HiddenInsetLocalScale      = new Vector3(m_VisibleInsetLocalScale.x * 0.5f, 0f, m_VisibleInsetLocalScale.z * 0.5f);

            m_OriginalIconLocalPosition    = m_IconContainer.localPosition;
            m_IconHighlightedLocalPosition = m_OriginalIconLocalPosition + Vector3.up * k_IconHighlightedLocalYOffset;
            m_IconPressedLocalPosition     = m_OriginalIconLocalPosition + Vector3.up * -k_IconHighlightedLocalYOffset;

            semiTransparent = false;
            m_FrameMaterial = MaterialUtils.GetMaterialClone(m_FrameRenderer);
            var frameMaterialColor = m_FrameMaterial.color;

            s_FrameOpaqueColor          = new Color(frameMaterialColor.r, frameMaterialColor.g, frameMaterialColor.b, 1f);
            m_SemiTransparentFrameColor = new Color(s_FrameOpaqueColor.r, s_FrameOpaqueColor.g, s_FrameOpaqueColor.b, 0.125f);
        }
        public override void Setup()
        {
            // Initial bounds must be set before the base.Setup() is called
            minBounds = new Vector3(k_MinBounds.x, k_MinBounds.y, 0.25f);
            m_CustomStartingBounds = new Vector3(k_MinBounds.x, k_MinBounds.y, 0.5f);

            base.Setup();

            ObjectUtils.Instantiate(m_ContentPrefab, m_WorkspaceUI.sceneContainer, false);
            m_MiniWorldUI  = GetComponentInChildren <MiniWorldUI>();
            m_GridMaterial = MaterialUtils.GetMaterialClone(m_MiniWorldUI.grid);

            var resetUI = ObjectUtils.Instantiate(m_RecenterUIPrefab, m_WorkspaceUI.frontPanel, false).GetComponentInChildren <ResetUI>();

            resetUI.resetButton.onClick.AddListener(ResetChessboard);
            foreach (var mb in resetUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }

            var parent         = m_WorkspaceUI.frontPanel.parent;
            var locatePlayerUI = ObjectUtils.Instantiate(m_LocatePlayerPrefab, parent, false);

            m_PlayerDirectionButton = locatePlayerUI.transform.GetChild(0);
            foreach (var mb in locatePlayerUI.GetComponentsInChildren <MonoBehaviour>())
            {
                var button = mb as Button;
                if (button)
                {
                    button.onClick.AddListener(RecenterOnPlayer);
                }
            }

            var arrow = ObjectUtils.Instantiate(m_PlayerDirectionArrowPrefab, parent, false);

            arrow.transform.localPosition = new Vector3(-0.232f, 0.03149995f, 0f);
            m_PlayerDirectionArrow        = arrow.transform;

            // Set up MiniWorld
            m_MiniWorld = GetComponentInChildren <MiniWorld>();
            m_MiniWorld.referenceTransform.position   = Vector3.up * k_InitReferenceYOffset * k_InitReferenceScale;
            m_MiniWorld.referenceTransform.localScale = Vector3.one * k_InitReferenceScale;

            // Set up Zoom Slider
            var sliderObject = ObjectUtils.Instantiate(m_ZoomSliderPrefab, m_WorkspaceUI.frontPanel, false);

            m_ZoomSliderUI                      = sliderObject.GetComponentInChildren <ZoomSliderUI>();
            m_ZoomSliderUI.sliding             += OnSliding;
            m_ZoomSliderUI.zoomSlider.maxValue  = Mathf.Log10(k_MaxZoomScale);
            m_ZoomSliderUI.zoomSlider.minValue  = Mathf.Log10(k_MinZoomScale);
            m_ZoomSliderUI.zoomSlider.direction = Slider.Direction.RightToLeft;             // Invert direction for expected ux; zoom in as slider moves left to right
            m_ZoomSliderUI.zoomSlider.value     = Mathf.Log10(k_InitReferenceScale);
            foreach (var mb in m_ZoomSliderUI.GetComponentsInChildren <MonoBehaviour>())
            {
                connectInterfaces(mb);
            }

            var zoomTooltip = sliderObject.GetComponentInChildren <Tooltip>();

            if (zoomTooltip)
            {
                zoomTooltip.tooltipText = "Drag the Handle to Zoom the Mini World";
            }

            var frontHandle = m_WorkspaceUI.directManipulator.GetComponent <BaseHandle>();

            frontHandle.dragStarted += DragStarted;
            frontHandle.dragEnded   += DragEnded;

            // Propagate initial bounds
            OnBoundsChanged();
        }
Exemple #28
0
 void Awake()
 {
     m_MenuFacesMaterial = MaterialUtils.GetMaterialClone(m_MenuFaceRotationOrigin.GetComponent <MeshRenderer>());
     m_MenuFacesColor    = m_MenuFacesMaterial.color;
     localBounds         = ObjectUtils.GetBounds(transform);
 }
Exemple #29
0
 void Awake()
 {
     m_UndoButtonMaterial = MaterialUtils.GetMaterialClone(m_UndoButtonMeshRenderer);
     m_RedoButtonMaterial = MaterialUtils.GetMaterialClone(m_RedoButtonMeshRenderer);
 }
Exemple #30
0
 void Start()
 {
     m_BackgroundMaterial = MaterialUtils.GetMaterialClone(m_Background);
     m_BackgroundMaterial.SetInt("_StencilRef", stencilRef);
 }