Пример #1
0
    //  Create & set-up the indicator panel
    private void InitializeIndicator()
    {
        //  If no custom indicator panel is assigned to this gameobject, the viewer default indicator panel will be used instead
        if (CustomIndicatorPanel == null)
        {
            CustomIndicatorPanel = viewer.DefaultIndicatorPanel;
        }

        //  If customIndicatorPanel is still null because there is no viewer default, throw error
        try
        {
            //  Create the runtime indicator object and assign it under the canvas.
            GameObject panel = Instantiate(CustomIndicatorPanel, Vector2.zero, Quaternion.identity) as GameObject;
            panel.name = name + " indicator";
            panel.transform.SetParent(viewer.IndicatorCanvas.transform);
            IPanel = panel.GetComponent <IndicatorPanel>();

            //  Set the offset position of the onscreen image.
            if (IPanel.OnScreen != null)
            {
                IPanel.OnScreen.transform.position += new Vector3(onScreenOffset.x, onScreenOffset.y, 0);
            }

            //  Assign the initial z position && scale value
            //previousZposition = IPanel.transform.position.z;
            //previousScale = IPanel.transform.localScale;

            //  Add this target to the list of targets if not already
            if (!IndicatorViewer.Targets.Contains(this))
            {
                IndicatorViewer.Targets.Add(this);
            }

            //  initial indicator toggle
            if (OnScreen(viewer.ViewerCamera.WorldToScreenPoint(transform.position), viewer.ViewerCamera))
            {
                if (IPanel.OnScreen != null)
                {
                    ToggleOnScreen(true);
                }
                if (IPanel.OffScreen != null)
                {
                    ToggleOffScreen(false);
                }
            }
            else
            {
                if (IPanel.OnScreen != null)
                {
                    ToggleOnScreen(false);
                }
                if (IPanel.OffScreen != null)
                {
                    ToggleOffScreen(true);
                }
            }
        }
        catch
        { Debug.LogError("The 'DefaultIndicatorPanel' requires a UnityUI Panel object!", viewer); }
    }
    IEnumerator CoCreateTargetCamera()
    {
        IPanel = ITarget.IndicatorPanel;

        while (IPanel == null)
        {
            IPanel = ITarget.IndicatorPanel;
            yield return(null);
        }

        //  Now that the indicator panel exist, create the camera
        CreateTargetCamera();
    }
    IEnumerator CoCreateDistanceTracker()
    {
        IPanel = ITarget.IndicatorPanel;

        while (IPanel == null)
        {
            IPanel = ITarget.IndicatorPanel;
            yield return(null);
        }

        //  Now that the indicator panel exist, create the tracker
        CreateDistanceTracker();
    }
Пример #4
0
    IEnumerator CoSetPlayerName()
    {
        //  find the panel until it is not null
        IndicatorPanel IPanel = GetComponent <IndicatorTarget>().IndicatorPanel;

        while (IPanel == null)
        {
            IPanel = GetComponent <IndicatorTarget>().IndicatorPanel;
            yield return(null);
        }

        //  Change name
        IPanel.OnScreen.GetComponentInChildren <Text>(true).text = Name;
    }
Пример #5
0
    IEnumerator CoCreateDistanceTracker()
    {
        IPanel = IndicatorPanel;

        while (IPanel == null)
        {
            IPanel = IndicatorPanel;
            yield return(null);
        }

        yield return(new WaitForSeconds(1f));

        //  Now that the indicator panel exist, create the tracker
        CreateDistanceTracker();
    }
Пример #6
0
    IEnumerator CoChangeColor(Color newColor)
    {
        //yield return new WaitForSeconds(0.15f);

        //  Change color of all the indicator panel items
        IndicatorPanel IPanel = GetComponent <IndicatorTarget>().IndicatorPanel;

        while (IPanel == null)
        {
            IPanel = GetComponent <IndicatorTarget>().IndicatorPanel;
            yield return(null);
        }

        //  Changes all graphic colors
        Graphic[] graphics = IPanel.GetComponentsInChildren <Graphic>(true);
        if (graphics.Length > 0)
        {
            for (int i = 0; i < graphics.Length; i++)
            {
                graphics[i].color = newColor;
            }
        }
    }
Пример #7
0
//Color module

    #region Change Color
    public void ChangeColor(Color newColor, bool random)
    {
        if (random)
        {
            newColor = new Color(UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f), UnityEngine.Random.Range(0f, 1f));
        }


        if (GetComponent <IndicatorTarget>() != null)
        {
            IndicatorPanel IPanel = GetComponent <IndicatorTarget>().IndicatorPanel;

            //  Changes all graphic colors
            Graphic[] graphics = IPanel.GetComponentsInChildren <Graphic>(true);
            if (graphics.Length > 0)
            {
                for (int i = 0; i < graphics.Length; i++)
                {
                    graphics[i].color = newColor;
                }
            }
        }
    }
Пример #8
0
 void Awake()
 {
     mSingleton = this;
 }