protected virtual void InitialiseHighlighter()
        {
            VRTK_BaseHighlighter existingHighlighter = VRTK_BaseHighlighter.GetActiveHighlighter(gameObject);

            //If no highlighter is found on the GameObject then create the default one
            if (existingHighlighter == null)
            {
                highlightObject.AddComponent <VRTK_MaterialColorSwapHighlighter>();
            }
            else
            {
                VRTK_SharedMethods.CloneComponent(existingHighlighter, highlightObject);
            }

            //Initialise highlighter and set highlight colour
            objectHighlighter = highlightObject.GetComponent <VRTK_BaseHighlighter>();
            objectHighlighter.unhighlightOnDisable = false;
            objectHighlighter.Initialise(highlightColor);
            objectHighlighter.Highlight(highlightColor);

            //if the object highlighter is using a cloned object then disable the created highlight object's renderers
            if (objectHighlighter.UsesClonedObject())
            {
                Renderer[] renderers = GetComponentsInChildren <Renderer>(true);
                for (int i = 0; i < renderers.Length; i++)
                {
                    if (!VRTK_PlayerObject.IsPlayerObject(renderers[i].gameObject, VRTK_PlayerObject.ObjectTypes.Highlighter))
                    {
                        renderers[i].enabled = false;
                    }
                }
            }
        }
Example #2
0
        private void InitialiseHighlighter()
        {
            var existingHighlighter = VRTK_BaseHighlighter.GetActiveHighlighter(gameObject);

            //If no highlighter is found on the GameObject then create the default one
            if (existingHighlighter == null)
            {
                highlightObject.AddComponent <VRTK_MaterialColorSwapHighlighter>();
            }
            else
            {
                VRTK_SharedMethods.CloneComponent(existingHighlighter, highlightObject);
            }

            //Initialise highlighter and set highlight colour
            objectHighlighter = highlightObject.GetComponent <VRTK_BaseHighlighter>();
            objectHighlighter.Initialise(highlightColor);
            objectHighlighter.Highlight(highlightColor);

            //if the object highlighter is using a cloned object then disable the created highlight object's renderers
            if (objectHighlighter.UsesClonedObject())
            {
                foreach (var renderer in GetComponentsInChildren <Renderer>(true))
                {
                    if (!VRTK_PlayerObject.IsPlayerObject(renderer.gameObject, VRTK_PlayerObject.ObjectTypes.Highlighter))
                    {
                        renderer.enabled = false;
                    }
                }
            }
        }
Example #3
0
        // Token: 0x06001222 RID: 4642 RVA: 0x00068A0C File Offset: 0x00066C0C
        protected virtual void InitialiseHighlighter()
        {
            VRTK_BaseHighlighter activeHighlighter = VRTK_BaseHighlighter.GetActiveHighlighter(base.gameObject);

            if (activeHighlighter == null)
            {
                this.highlightObject.AddComponent <VRTK_MaterialColorSwapHighlighter>();
            }
            else
            {
                VRTK_SharedMethods.CloneComponent(activeHighlighter, this.highlightObject, false);
            }
            this.objectHighlighter = this.highlightObject.GetComponent <VRTK_BaseHighlighter>();
            this.objectHighlighter.unhighlightOnDisable = false;
            this.objectHighlighter.Initialise(new Color?(this.highlightColor), null);
            this.objectHighlighter.Highlight(new Color?(this.highlightColor), 0f);
            if (this.objectHighlighter.UsesClonedObject())
            {
                foreach (Renderer renderer in base.GetComponentsInChildren <Renderer>(true))
                {
                    if (!VRTK_PlayerObject.IsPlayerObject(renderer.gameObject, VRTK_PlayerObject.ObjectTypes.Highlighter))
                    {
                        renderer.enabled = false;
                    }
                }
            }
        }
Example #4
0
 // Token: 0x06001548 RID: 5448 RVA: 0x00075758 File Offset: 0x00073958
 protected virtual void AddHighlighterToElement(Transform element, VRTK_BaseHighlighter parentHighlighter, VRTK_BaseHighlighter overrideHighlighter)
 {
     if (element != null)
     {
         ((VRTK_BaseHighlighter)VRTK_SharedMethods.CloneComponent((overrideHighlighter != null) ? overrideHighlighter : parentHighlighter, element.gameObject, false)).Initialise(null, this.highlighterOptions);
     }
 }
Example #5
0
 private void AddHighlighterToElement(Transform element, VRTK_BaseHighlighter parentHighlighter, VRTK_BaseHighlighter overrideHighlighter)
 {
     if (element)
     {
         var highlighter = (overrideHighlighter != null ? overrideHighlighter : parentHighlighter);
         VRTK_BaseHighlighter clonedHighlighter = (VRTK_BaseHighlighter)VRTK_SharedMethods.CloneComponent(highlighter, element.gameObject);
         clonedHighlighter.Initialise(null, highlighterOptions);
     }
 }
Example #6
0
 protected virtual void AddHighlighterToElement(Transform element, VRTK_BaseHighlighter parentHighlighter, VRTK_BaseHighlighter overrideHighlighter)
 {
     if (element != null)
     {
         VRTK_BaseHighlighter exitingHighlighter = element.GetComponent <VRTK_BaseHighlighter>();
         if (exitingHighlighter != null)
         {
             Destroy(exitingHighlighter);
         }
         VRTK_BaseHighlighter highlighter       = (overrideHighlighter != null ? overrideHighlighter : parentHighlighter);
         VRTK_BaseHighlighter clonedHighlighter = (VRTK_BaseHighlighter)VRTK_SharedMethods.CloneComponent(highlighter, element.gameObject);
         clonedHighlighter.Initialise(null, element.gameObject, highlighterOptions);
     }
 }