AlignViewToObject() публичный Метод

public AlignViewToObject ( Transform t ) : void
t UnityEngine.Transform
Результат void
Пример #1
0
        void PastePlacement()
        {
            var tr        = m_SceneView.camera.transform;
            var placement = Clipboard.GetCustomValue <TransformWorldPlacement>();

            tr.position   = placement.position;
            tr.rotation   = placement.rotation;
            tr.localScale = placement.scale;
            m_SceneView.AlignViewToObject(tr);
            m_SceneView.Repaint();
        }
Пример #2
0
    void CreateNewScreen()
    {
        Undo.RegisterCreatedObjectUndo(uiManager, uiManager.name);
        GameObject newUIScreenManager = uiManager.CreateNewUIScreenManager();

        if (newUIScreenManager != null)
        {
            newUIScreenManager.transform.SetSiblingIndex(uiManager.GetLastScreenSiblingIndex());
            ArrayList sceneViews = UnityEditor.SceneView.sceneViews;
            if (sceneViews != null)
            {
                if (sceneViews.Count > 0)
                {
                    UnityEditor.SceneView sceneView = (UnityEditor.SceneView)sceneViews[0];
                    sceneView.AlignViewToObject(newUIScreenManager.transform);
                }
            }
        }
    }
Пример #3
0
    static void CreateNewUIScreen()
    {
        UIManager uiManager = FindObjectOfType <UIManager>();

        if (uiManager != null)
        {
            Undo.RegisterCreatedObjectUndo(uiManager, uiManager.name);
            GameObject newUIScreenManager = uiManager.CreateNewUIScreenManager();
            Selection.activeObject = newUIScreenManager;
            ArrayList sceneViews = UnityEditor.SceneView.sceneViews;
            if (sceneViews != null)
            {
                if (sceneViews.Count > 0)
                {
                    UnityEditor.SceneView sceneView = (UnityEditor.SceneView)sceneViews[0];
                    sceneView.AlignViewToObject(newUIScreenManager.transform);
                }
            }
        }
        else
        {
            EditorUtility.DisplayDialog("Cant find UIManager", "A UIManager gameobject in the scene is necessary for this feature to work correctly", "Ok");
        }
    }
 private void Follow()
 {
     sceneView.camera.transform.position = mainCamTrans.position - vecOffset;
     sceneView.camera.transform.rotation = Quaternion.LookRotation((sceneView.camera.transform.position - mainCamTrans.position) * -1);
     sceneView.AlignViewToObject(sceneView.camera.transform);
 }
Пример #5
0
    void CreateFromSelected()
    {
        if (Selection.gameObjects.Length > 0)
        {
            for (int i = 0; i < Selection.gameObjects.Length; i++)
            {
                UIScreenManager uism = Selection.gameObjects[i].GetComponent <UIScreenManager>();
                if (uism != null)
                {
                    Undo.RegisterCreatedObjectUndo(uiManager, uiManager.name);

                    PrefabType      pType              = PrefabUtility.GetPrefabType(uism.gameObject);
                    bool            isPrefab           = pType == PrefabType.Prefab;
                    UIScreenManager newUIScreenManager = null;
                    //Debug.Log("Selection type ["+pType+"]");
                    if (isPrefab)
                    {
                        //	Debug.Log("Creating screen from prefab reference");
                        GameObject instancedGO = (GameObject)PrefabUtility.InstantiatePrefab(Selection.gameObjects[i]);
                        if (instancedGO != null)
                        {
                            UIScreenManager instancedUISM = instancedGO.GetComponent <UIScreenManager>();
                            if (instancedUISM != null)
                            {
                                newUIScreenManager = uiManager.CreateNewUIScreenControllerFromSceneObject(instancedUISM);
                                if (newUIScreenManager == null)                               //delete newly created object
                                {
                                    DestroyImmediate(instancedGO);
                                    EditorUtility.DisplayDialog("Cant create.", "For a new UIScreenManager to be registered/created it must have a unique Id.", "Ok");
                                }
                            }
                        }
                    }
                    else
                    {
                        newUIScreenManager = uiManager.CreateNewUIScreenControllerFromSceneObject(uism);
                    }

                    if (newUIScreenManager != null)
                    {
                        newUIScreenManager.CachedTransform.SetSiblingIndex(uiManager.GetLastScreenSiblingIndex());
                        Object prefab = PrefabUtility.GetCorrespondingObjectFromSource((Object)newUIScreenManager.gameObject);
                        if (prefab != null)
                        {
                            //is a prefab
                            string          path       = AssetDatabase.GetAssetPath(prefab);
                            UIScreenManager prefabUIsm = AssetDatabase.LoadAssetAtPath <UIScreenManager>(path);
                            if (prefabUIsm != null)
                            {
                                for (int j = 0; j < uiManager.allScreenControllers.Count; j++)
                                {
                                    if (uiManager.allScreenControllers[j].uiUniqueId == newUIScreenManager.uniqueScreenId)
                                    {
                                        uiManager.allScreenControllers[j].uiScreenPrefab = prefabUIsm;
                                        break;
                                    }
                                }
                            }
                        }

                        ArrayList sceneViews = UnityEditor.SceneView.sceneViews;
                        if (sceneViews != null)
                        {
                            if (sceneViews.Count > 0)
                            {
                                UnityEditor.SceneView sceneView = (UnityEditor.SceneView)sceneViews[0];
                                sceneView.AlignViewToObject(newUIScreenManager.transform);
                            }
                        }
                    }
                }
            }
        }
    }
Пример #6
0
    public override void OnInspectorGUI()
    {
        bool wasDestroyed = false;

        if (uiScreenManager != null && serializedObj != null)
        {
            GUI.enabled = false;
            script      = EditorGUILayout.ObjectField("Script:", script, typeof(MonoScript), false) as MonoScript;
            GUI.enabled = true;
            // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
            serializedObj.Update();
            _isPopUp = serializedObj.FindProperty("isPopUp").boolValue;
            if (Selection.objects.Length == 1)
            {
                PrefabType pType    = PrefabUtility.GetPrefabType(uiScreenManager.gameObject);
                bool       isPrefab = pType == PrefabType.Prefab;
                if (!isPrefab)
                {
                    if (GUILayout.Button("Update Id In Manager"))
                    {
                        if (_isPopUp)
                        {
                            PopUpsManager popUpsManager = FindObjectOfType <PopUpsManager>();
                            if (popUpsManager != null)
                            {
                                UpdateIdOnPopUpsManager(popUpsManager);
                            }
                        }
                        else
                        {
                            UIManager uiManager = FindObjectOfType <UIManager>();
                            if (uiManager != null)
                            {
                                UpdateIdOnUIManager(uiManager);
                            }
                        }
                    }
                    if (GUILayout.Button("Switch " + (uiScreenManager.gameObject.activeSelf ? "OFF" : "ON")))
                    {
                        if (_isPopUp)
                        {
                            PopUpsManager popUpManager = FindObjectOfType <PopUpsManager>();
                            if (popUpManager != null)
                            {
                                popUpManager.SwitchById(uiScreenManager.uniqueScreenId, !uiScreenManager.gameObject.activeSelf);
                            }
                        }
                        else
                        {
                            UIManager uiManager = FindObjectOfType <UIManager>();
                            if (uiManager != null)
                            {
                                uiManager.SwitchScreenById(uiScreenManager.uniqueScreenId, !uiScreenManager.gameObject.activeSelf);
                            }
                        }
                    }
                    if (GUILayout.Button("Enable as SOLO"))
                    {
                        if (_isPopUp)
                        {
                            PopUpsManager popUpManager = FindObjectOfType <PopUpsManager>();
                            if (popUpManager != null)
                            {
                                popUpManager.SwitchSolo(uiScreenManager.uniqueScreenId);
                            }
                        }
                        else
                        {
                            UIManager uiManager = FindObjectOfType <UIManager>();
                            if (uiManager != null)
                            {
                                uiManager.SwitchToScreenWithId(uiScreenManager.uniqueScreenId);
                                ArrayList sceneViews = UnityEditor.SceneView.sceneViews;
                                if (sceneViews != null)
                                {
                                    if (sceneViews.Count > 0)
                                    {
                                        UnityEditor.SceneView sceneView = (UnityEditor.SceneView)sceneViews[0];
                                        sceneView.AlignViewToObject(uiScreenManager.transform);
                                    }
                                }
                            }
                        }
                    }
                    if (GUILayout.Button("Despawn"))
                    {
                        wasDestroyed = true;
                        lastUIScreenManagerWasDespawned = true;
                        DestroyImmediate(uiScreenManager.gameObject);
                    }
                    if (GUILayout.Button("Destroy And Remove"))
                    {
                        wasDestroyed = true;
                        DestroyImmediate(uiScreenManager.gameObject);
                    }
                }
            }
        }
        if (target != null && !wasDestroyed)
        {
            //DrawDefaultInspector();
            EditorGUILayout.PropertyField(serializedObj.FindProperty("mustShowDebugInfo"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("mustRegisterForBackOperations"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("mustActiveRecursively"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("mustSurviveSceneChange"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("uniqueScreenId"));
            EditorGUILayout.PropertyField(serializedObj.FindProperty("isPopUp"));
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(serializedObj.FindProperty("screenCameraDepth"));
            if (EditorGUI.EndChangeCheck())
            {
                //try to update camera depth
                Camera camera = uiScreenManager.gameObject.GetComponent <Camera>();
                if (camera != null)
                {
                    float depth = serializedObj.FindProperty("screenCameraDepth").floatValue;
                    camera.depth = depth;
                }
            }
        }
        if (serializedObject != null && !wasDestroyed)
        {
            // Apply changes to the serializedProperty - always do this in the end of OnInspectorGUI.
            serializedObject.ApplyModifiedProperties();
        }
    }