Пример #1
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();
        }
Пример #2
0
        //Show GUI in Inspector
        public override void OnInspectorGUI()
        {
            if (_myTarget == null)
            {
                return;
            }

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

            //HANDLE INSPECTOR GUI BUTTONS
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Load All"))
            {
                _myTarget.LoadAllAssets();
            }

            if (GUILayout.Button("Unload All"))
            {
                _myTarget.UnloadAllAssets();
            }
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Refresh Asset Data"))
            {
                _myTarget.RefreshAssetData();
            }
            EditorGUILayout.EndHorizontal();

            //DRAW CUSTOM INSPECTOR
            DrawDefaultInspector();
        }