コード例 #1
0
    public static Highlighter HighlightObject(Transform _object, Color _color, Color _secondaryColor, bool _heritRemainingTime = false)
    {
        HighlighterDatas datas         = Resources.Load <HighlighterDatas>("HighlighterDatas");
        float            remainingTime = datas.duration;

        if (instance != null)
        {
            if (_heritRemainingTime)
            {
                remainingTime = instance.remainingLifeTime;
                if (remainingTime <= 0)
                {
                    return(null);
                }
            }
            Destroy(instance);
        }

        Highlighter highlighter = _object.GetComponent <Highlighter>();

        if (highlighter != null)
        {
            Destroy(highlighter);
        }
        Highlighter newHighlighter = _object.gameObject.AddComponent <Highlighter>();

        newHighlighter.remainingLifeTime = remainingTime;
        Shader.SetGlobalColor("_HighlightColor", _color);
        Shader.SetGlobalColor("_SecondOutlineColor", _secondaryColor);
        newHighlighter.StartCoroutine(newHighlighter.Init_C());
        instance = newHighlighter;
        return(newHighlighter);
    }
コード例 #2
0
    /*
     * Stores all the previous materials on the renderers
     * Replace all the materials by the "Highlight" material
     * Fade-in:
     *      - Highlight circle grows from the center and opacity will fade in
     *      - Highlight arrow will spawn from above, go down and opacity will fade in
     *      - New materials emissive starts at 1 and goes up
     *
     * Update:
     *      - Highlight circle scales up and down
     *      - Highlight arrow goes up and down
     *      - New material emissive goes heavy and light
     *
     * Fade-out:
     *      - Highlight  circle opacity fade out
     *      - Highlight arrow opacity fade out
     *      - New materials emissive goes from current to 1
     */

    public static void HighlightBall(bool _heritRemainingTime = false)
    {
        HighlighterDatas datas = Resources.Load <HighlighterDatas>("HighlighterDatas");

        instance = HighlightObject(BallBehaviour.instance.transform, datas.defaultFirstColor, datas.defaultSecondColor, _heritRemainingTime);
        if (instance != null)
        {
            instance.isOnBall = true;
        }
    }
コード例 #3
0
    public void Init()
    {
        //Generates circle, arrow, and replace materials
        CheckIfHeldByPlayer();

        datas = Resources.Load <HighlighterDatas>("HighlighterDatas");
        Shader.SetGlobalFloat("_MinEmissiveIntensity", datas.minEmissionForce);
        Shader.SetGlobalFloat("_MaxEmissiveIntensity", datas.maxEmissionForce);
        Shader.SetGlobalFloat("_EmissiveLerpSpeed", datas.emissionLerpSpeed);
        materialReplacers = new List <MaterialReplacer>();
        foreach (Renderer renderer in GetComponentsInChildren <Renderer>())
        {
            if (renderer.GetType() == typeof(ParticleSystemRenderer))
            {
                continue;
            }
            MaterialReplacer newReplacer = renderer.gameObject.AddComponent <MaterialReplacer>();
            materialReplacers.Add(newReplacer);
            newReplacer.ReplaceMaterial(Resources.Load <Material>("HighlightResource/M_HighlightedObject"));
        }

        circle = Instantiate(Resources.Load <GameObject>("HighlightResource/HighlightCircle"));
        circle.transform.SetParent(transform);
        circle.transform.localPosition = Vector3.zero + new Vector3(0, datas.circleZOffset, 0);
        circle.transform.localRotation = Quaternion.identity;
        circle.transform.localScale    = Vector3.one * datas.circleMinSize;

        arrow = Instantiate(Resources.Load <GameObject>("HighlightResource/HighlightArrow"));
        arrow.transform.SetParent(transform);
        arrow.transform.localPosition = Vector3.zero + new Vector3(0, datas.arrowMinZOffset, 0);
        arrow.transform.localRotation = Quaternion.identity;
        arrow.transform.localScale    = Vector3.one;

        previousParent = transform.parent;
        passedTime     = 0;
        fadeCoroutine  = StartCoroutine(FadeIn_C());
    }