Ejemplo n.º 1
0
 private void ConstructGameVisualizations()
 {
     foreach (var gameObject in gameDrawList)
     {
         var text = GameObject.Instantiate(textPrefab);
         text.gameObject.name = gameObject.Key.name + " Member Visualizer Text";
         //text.transform.localPosition = Vector3.zero;
         MemberVisualizationRenderSettings rs = renderSettingsMap[gameObject.Key];
         text.fontSize = rs.fontSize;
         //text.fontSize = fontSize;
         textInstanceMap.Add(gameObject.Key, text);
     }
 }
Ejemplo n.º 2
0
        private void UpdateRenderSettingsList()
        {
            // 1. Get the list of unique GameObjects
            var selectedGameObjects = new List <GameObject>();

            foreach (var memberField in getters)
            {
                var go = memberField.member.target as GameObject;
                if (go == null)
                {
                    continue;
                }
                bool isPresent = selectedGameObjects.Contains(go);
                if (!isPresent)
                {
                    selectedGameObjects.Add(go);
                }
            }

            // No objects are being inspected
            if (selectedGameObjects.Empty())
            {
                return;
            }

            // 2. Remove render settings for missing GameObjects
            renderSettingsList.RemoveAll(x => selectedGameObjects.Contains(x.gameObject) == false);

            // 3. Add render settings for new GameObjects
            foreach (var go in selectedGameObjects)
            {
                MemberVisualizationRenderSettings rs = renderSettingsList.Find(x => x.gameObject == go);
                bool isPresent = rs == null;
                if (isPresent)
                {
                    renderSettingsList.Add(new MemberVisualizationRenderSettings()
                    {
                        gameObject = go
                    });
                }
            }
        }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------/
        // Methods
        //------------------------------------------------------------------------/
        private void DrawSceneVisualization()
        {
#if UNITY_EDITOR
            // For every GameObject, get all the properties for it
            foreach (var gameObject in sceneDrawList)
            {
                MemberVisualizationRenderSettings rs = renderSettingsMap[gameObject.Key];
                Vector3 pos = gameObject.Key.transform.position;
                pos += rs.offset;
                UnityEditor.Handles.BeginGUI();
                {
                    string description = GetDescription(gameObject.Value);
                    Rect   rect        = UnityEditor.HandleUtility.WorldPointToSizedRect(pos, new GUIContent(description), textStyle);
                    UnityEditor.Handles.DrawSolidRectangleWithOutline(rect, backgroundColor, outlineColor);
                    UnityEditor.Handles.Label(pos, description, textStyle);
                }
                UnityEditor.Handles.EndGUI();
            }
#endif
        }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------/
        // Methods
        //------------------------------------------------------------------------/
        private void OnPoll()
        {
            foreach (var memberField in getters)
            {
                memberField.Update();
            }

            Vector3 cameraPosition = Camera.main.transform.position;
            Vector3 cameraNormal   = Camera.main.transform.forward;

            foreach (var kp in gameDrawList)
            {
                GameObject  go                       = kp.Key;
                string      description              = GetDescription(kp.Value);
                TextMeshPro textInstance             = textInstanceMap[go];
                MemberVisualizationRenderSettings rs = renderSettingsMap[go];
                textInstance.transform.position = go.transform.position + rs.offset;
                textInstance.fontSize           = rs.fontSize;
                textInstance.text = description;
                // Apply billboarding
                textInstance.transform.LookAt(cameraNormal + textInstance.transform.position);
                textInstance.transform.Rotate(0, 180f, 0);
            }
        }