예제 #1
0
        private void OnEnable()
        {
            _myTarget = (AsyncAssetLoader)target;

            SceneView.duringSceneGui += v => CastSceneViewEditor(_myTarget);

            if (SceneView.lastActiveSceneView)
            {
                SceneView.lastActiveSceneView.Repaint();
            }
        }
예제 #2
0
        private static void CastSceneViewEditor(AsyncAssetLoader _myTarget)
        {
            if (_myTarget == null)
            {
                return;
            }

            //check if the target is selected in hierarchy/inspector
            if (Selection.activeGameObject != _myTarget.gameObject)
            {
                return;
            }

            CheckHotKey(_myTarget);

            Handles.BeginGUI();

            float screenHeight = SceneView.currentDrawingSceneView.position.size.y;

            Vector3 targetPos   = _myTarget.gameObject.transform.position;
            Vector3 screenPoint = SceneView.lastActiveSceneView.camera.WorldToScreenPoint(targetPos);

            // this prevents the GUI control from being drawn if you aren't looking at it
            if (screenPoint.z > 0)
            {
                Vector2 buttonPos1 = new Vector2(screenPoint.x - buttonSize.x * 0.5f, screenHeight - screenPoint.y - buttonSize.y - 50);

                if (!_myTarget.AssetsAreLoaded)
                {
                    GUI.backgroundColor = loadColor;
                    GUI.contentColor    = Color.black;
                    if (GUI.Button(new Rect(buttonPos1, buttonSize), "Load!"))
                    {
                        _myTarget.LoadAllAssets();
                        Debug.Log("LOADING Assets called.");
                    }
                }
                else
                {
                    GUI.backgroundColor = unloadColor;
                    GUI.contentColor    = Color.black;
                    if (GUI.Button(new Rect(buttonPos1, buttonSize), "Unload!"))
                    {
                        _myTarget.UnloadAllAssets();
                    }
                }
            }

            Handles.EndGUI();
        }
예제 #3
0
        /// <summary>
        /// placeholder to implement a shortcut
        /// </summary>
        public static void CheckHotKey(AsyncAssetLoader target)
        {
            if (target == null)
            {
                return;
            }

            //HANDLE TARGET TRANSFORM/OVERRIDES VISUALIZATION
            Event e = Event.current;

            switch (e.type)
            {
            case EventType.KeyUp:
            {
                if (e.keyCode == (KeyCode.A))
                {
                    Debug.Log("refreshing asset data..");
                    target.RefreshAssetData();
                }
                break;
            }
            }
        }