Exemple #1
0
 static Singleton()
 {
     if (instance == null)
     {
         instance = new TextGizmo();
     }
 }
Exemple #2
0
        void OnDrawGizmos()
        {
            if (!DEBUG_MODE)
            {
                return;
            }

            foreach (Vector2 pt in debugHit.Keys)
            {
                Gizmos.color = debugHit[pt];
                Gizmos.DrawSphere(new Vector3(pt.x, pt.y, 1), 0.13f);
            }

            foreach (Vector3 pt in debugText.Keys)
            {
                TextGizmo.Draw(new Vector3(pt.x, pt.y, 1), debugText[pt]);
            }
        }
Exemple #3
0
        //Draw collisionIgnoreHeight gizmos
        private void OnDrawGizmosSelected()
        {
            Vector3 startPoint = transform.TransformPoint(Vector3.up * collisionIgnoreHeight);

            Gizmos.color = Color.red;
            Gizmos.DrawRay(startPoint, transform.forward);
            Gizmos.DrawRay(startPoint, -transform.forward);
            Gizmos.DrawRay(startPoint, transform.right);
            Gizmos.DrawRay(startPoint, -transform.right);

            foreach (var t in gameObject.GetComponentsInChildren <Transform>().Where(x => x.name.Contains("wheel")))
            {
                try
                {
                    TextGizmo.Draw(t.position, damageLogger[System.Array.IndexOf(deformMeshes.Select(x => x.name).ToArray(), t.name)].ToString());
                }
                catch
                {
                }
            }
        }
Exemple #4
0
 public static void Init()
 {
     tg = new TextGizmo();
 }
Exemple #5
0
 private void Awake()
 {
     TextGizmo.Init();
 }
Exemple #6
0
        public void OnDrawGizmos()
        {
            for (int i = 0; i < CurrentSearches.Count; i++)
            {
                WidgetSearch w = CurrentSearches [i];
                w.FinalScore        = WidgetSearch.CalculateScore(w);
                CurrentSearches [i] = w;
            }
            CurrentSearches.Sort();

            Gizmos.color = Color.Lerp(Color.magenta, Color.cyan, 0.5f);
            Gizmos.DrawWireCube(LastBrowserBounds.center, LastBrowserBounds.size);

            if (LastDirection == SearchDirection.Left || LastDirection == SearchDirection.Right)
            {
                Gizmos.color = Color.Lerp(Color.red, Color.yellow, 0.5f);
                Gizmos.DrawLine(CurrentSearch.WorldBounds.max + (Vector3.left * 100f), CurrentSearch.WorldBounds.max + (Vector3.right * 100f));
                Gizmos.color = Color.blue;
                Gizmos.DrawLine(CurrentSearch.WorldBounds.min + (Vector3.left * 100f), CurrentSearch.WorldBounds.min + (Vector3.right * 100f));
            }
            else
            {
                Gizmos.color = Color.Lerp(Color.red, Color.yellow, 0.5f);
                Gizmos.DrawLine(CurrentSearch.WorldBounds.max + (Vector3.down * 100f), CurrentSearch.WorldBounds.max + (Vector3.up * 100f));
                Gizmos.color = Color.blue;
                Gizmos.DrawLine(CurrentSearch.WorldBounds.min + (Vector3.down * 100f), CurrentSearch.WorldBounds.min + (Vector3.up * 100f));
            }

            Gizmos.color = Color.yellow;
            Gizmos.DrawSphere(ScreenSearchOrigin, 0.05f);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(LastMouseCursorResult, 0.05f);
            Gizmos.color = Color.green;
            Gizmos.DrawWireCube(CurrentWidgetBounds.center, CurrentWidgetBounds.size);
            Gizmos.DrawWireCube(CurrentWidgetBounds.center, CurrentWidgetBounds.size * 1.005f);
            Gizmos.color = Color.red;
            Gizmos.DrawWireCube(PreviousSearchBounds.center, PreviousSearchBounds.size);
            Gizmos.color = Color.cyan;
            switch (LastDirection)
            {
            default:
            case SearchDirection.Up:
                DrawArrow.ForGizmo(PreviousSearchBounds.center, Vector3.up * 0.25f);
                break;

            case SearchDirection.Down:
                DrawArrow.ForGizmo(PreviousSearchBounds.center, Vector3.down * 0.25f);
                break;

            case SearchDirection.Left:
                DrawArrow.ForGizmo(PreviousSearchBounds.center, Vector3.left * 0.25f);
                break;

            case SearchDirection.Right:
                DrawArrow.ForGizmo(PreviousSearchBounds.center, Vector3.right * 0.25f);

                break;
            }
            Gizmos.color = Color.magenta;
            if (LastSearchDirection != Vector3.zero)
            {
                DrawArrow.ForGizmo(PreviousSearchBounds.center + Vector3.up * 0.25f, LastSearchDirection * 0.35f, 0.2f, 25f);
            }

            if (CurrentSearches.Count > 0)
            {
                //skip the first one
                Color searchColor = Color.green;
                for (int i = 0; i < CurrentSearches.Count; i++)
                {
                    WidgetSearch s           = CurrentSearches [i];
                    Bounds       worldBounds = s.WorldBounds;
                    if (!s.Widget.IsEmpty)
                    {
                        worldBounds = s.Widget.BoxCollider.bounds;
                    }
                    float normalizedAmount = (float)i / (float)(CurrentSearches.Count);
                    TextGizmo.Draw(SearchCamera, worldBounds.center + Vector3.up * 0.01f, s.Dot.ToString());
                    //TextGizmo.Draw(SearchCamera, s.WorldBounds.center + Vector3.up * 0.01f, Mathf.FloorToInt(s.FinalScore * 1000).ToString());
                    //TextGizmo.Draw(SearchCamera, s.WorldBounds.center + Vector3.up * 0.01f, Mathf.FloorToInt(s.PrimaryOverlap).ToString());
                    if (i == 0)
                    {
                        searchColor  = Color.green;
                        Gizmos.color = searchColor;
                        Gizmos.DrawWireCube(worldBounds.center, worldBounds.size * 0.98f);
                        Gizmos.DrawWireCube(worldBounds.center, worldBounds.size * 1.015f);
                    }
                    else
                    {
                        searchColor = Colors.Alpha(Colors.BlendThree(Color.Lerp(Color.green, Color.yellow, 0.2f), Color.yellow, Color.magenta, normalizedAmount), 0.5f);
                    }
                    Gizmos.color = searchColor;
                    Gizmos.DrawCube(worldBounds.center, worldBounds.size);
                    Gizmos.color = Colors.Alpha(searchColor, 0.5f);
                    Gizmos.DrawWireCube(worldBounds.center, worldBounds.size * 0.99f);
                }
            }
        }
Exemple #7
0
    /// <summary>>
    /// Graphically represents the Neural network
    /// </summary>
    public void Print(Vector3 pos, int sizeOffset, bool ignoreY = false)
    {
        List <Vector3> Positions = new List <Vector3> ();

        float nodeDistance = 1.0f;
        float radius       = 0.2f;
        float boxsize      = 0.6f;
        float xOffset      = sizeOffset * nodeDistance;
        float yOffset      = _inputCount * nodeDistance * 2 * _index;

        if (ignoreY)
        {
            yOffset = 0.0f;
        }


        Vector3 myPos1 = new Vector3(pos.x - nodeDistance + xOffset, pos.y - yOffset + nodeDistance * 2, pos.z);

        TextGizmo.Draw(myPos1, _index.ToString());

        myPos1 = new Vector3(pos.x - nodeDistance + xOffset, pos.y - yOffset + nodeDistance, pos.z);
        TextGizmo.Draw(myPos1, _fitness.ToString());

        myPos1 = new Vector3(pos.x - nodeDistance + xOffset, pos.y - yOffset + nodeDistance / 2, pos.z);
        TextGizmo.Draw(myPos1, _probability.ToString());

        myPos1 = new Vector3(pos.x - nodeDistance + xOffset + (NodeCollection.Count - _inputCount - _outputCount + 2) * nodeDistance, pos.y - yOffset + nodeDistance / 2, pos.z);
        List <float> results = GetOutputs();

        Gizmos.color = new Color(results[0], results[1], results[2]);
        Gizmos.DrawCube(myPos1, new Vector3(boxsize, boxsize, boxsize));


        Gizmos.color = new Color(0.2f, 0.2f, 0.2f);
        //Draw inputs
        for (int i = 0; i < _inputCount; i++)
        {
            Vector3 myPos = new Vector3(pos.x + xOffset + i * 0.2f, pos.y - nodeDistance * i - yOffset, pos.z);
            Positions.Add(myPos);
            Gizmos.color = Color.red;
            Gizmos.DrawSphere(myPos, radius);
            //TextGizmo.Draw( myPos,  NodeCollection[i]._value.ToString());
            TextGizmo.Draw(myPos, NodeCollection[i]._nodeIndex.ToString());
        }
        //Draw OutPuts
        for (int i = 0; i < _outputCount; i++)
        {
            Vector3 myPos = new Vector3(pos.x - nodeDistance + xOffset + (NodeCollection.Count - _inputCount - _outputCount + 2) * nodeDistance + i * 0.2f, pos.y - nodeDistance * i - yOffset, pos.z);
            Positions.Add(myPos);
            Gizmos.color = Color.blue;
            Gizmos.DrawSphere(myPos, radius);
            TextGizmo.Draw(myPos, NodeCollection[i + _inputCount]._nodeIndex.ToString());
            //TextGizmo.Draw(myPos, NodeCollection[NodeCollection.Count - _inputCount + i]._value.ToString());
        }
        //Draw Hidden Nodes
        for (int i = 0; i < NodeCollection.Count - _inputCount - _outputCount; i++)
        {
            Vector3 myPos = new Vector3(pos.x + nodeDistance * (i + 1) + xOffset + i * 0.2f, pos.y - (Positions[0].y - Positions[_inputCount - 1].y) * ((float)i / (NodeCollection.Count - _inputCount - _outputCount)) - nodeDistance / 2 - yOffset, pos.z);
            Positions.Add(myPos);
            Gizmos.color = Color.black;
            Gizmos.DrawSphere(myPos, radius);
            //TextGizmo.Draw(myPos, NodeCollection[i + _inputCount]._value.ToString());
            TextGizmo.Draw(myPos, NodeCollection[i + _inputCount + _outputCount]._nodeIndex.ToString());
        }


        for (int i = 0; i < NeuralNetwork.Count; i++)
        {
            if (NeuralNetwork[i]._weight > 0)
            {
                Gizmos.color = new Color(0, 1.0f, 0);
            }
            else if (NeuralNetwork[i]._weight < 0)
            {
                Gizmos.color = new Color(1.0f, 0, 0);
            }
            if (!NeuralNetwork[i]._enabled)
            {
                Gizmos.color = new Color(0, 0, 0);
            }
            Gizmos.DrawLine(Positions[NeuralNetwork[i]._in], Positions[NeuralNetwork[i]._out]);
        }
    }