Exemple #1
0
 /// <summary>
 /// Draws the controls for setting up the scene.
 /// </summary>
 private void DrawSceneSetup()
 {
     ManagerUtility.DrawControlBox("Manager Setup", null, "Adds the scene-level manager components to the scene.", true, "Add Managers", AddManagers, string.Empty);
     ManagerUtility.DrawControlBox("Camera Setup", DrawCameraViewTypes, "Sets up the camera within the scene to use the Ultimate Character Controller Camera Controller component.",
                                   m_CanCreateCamera, "Setup Camera", SetupCamera, string.Empty);
     ManagerUtility.DrawControlBox("UI Setup", null, "Adds the UI monitors to the scene.", true, "Add UI", AddUI, string.Empty);
     ManagerUtility.DrawControlBox("Virtual Controls Setup", null, "Adds the virtual controls to the scene.", true, "Add Virtual Controls", AddVirtualControls, string.Empty);
 }
Exemple #2
0
 /// <summary>
 /// Draws the controls for button and input setup.
 /// </summary>
 private void DrawProjectSetup()
 {
     ManagerUtility.DrawControlBox("Button Mappings", null, "This option will add the default button mappings to the Unity Input Manager. If you are using a custom button mapping or " +
                                   "an input integration then you do not neeed to update the Unity button mappings.", true, "Update Buttons",
                                   Utility.UnityInputBuilder.UpdateInputManager, "The button mappings were successfully updated.");
     GUILayout.Space(10);
     ManagerUtility.DrawControlBox("Layers", null, "This option will update the project layers to the default character controller layers. The layers do not need to be updated " +
                                   "if you have already setup a custom set of layers.", true, "Update Layers", UpdateLayers, "The layers were successfully updated.");
 }
Exemple #3
0
        /// <summary>
        /// Initialize the manager after deserialization.
        /// </summary>
        public override void Initialize(MainManagerWindow mainManagerWindow)
        {
            base.Initialize(mainManagerWindow);

            // Look for the ItemCollection within the scene if it isn't already populated.
            if (m_ItemCollection == null)
            {
                m_ItemCollection = ManagerUtility.FindItemCollection(m_MainManagerWindow);
            }

            // The ItemCollection may have been serialized.
            if (m_ItemCollection != null)
            {
                // The category may be invalid.
                var categories = m_ItemCollection.Categories;
                if (categories != null)
                {
                    for (int i = categories.Length - 1; i > -1; --i)
                    {
                        if (categories[i] != null)
                        {
                            continue;
                        }
                        ArrayUtility.RemoveAt(ref categories, i);
                    }
                    m_ItemCollection.Categories = categories;
                }

                // The CategoryState would have been reconstructed after deserialization so update the state within the tree.
                m_CategoryTreeView.state.expandedIDs   = m_CategoryTreeViewState.expandedIDs;
                m_CategoryTreeView.state.lastClickedID = m_CategoryTreeViewState.lastClickedID;
                m_CategoryTreeView.state.searchString  = m_CategoryTreeViewState.searchString;
                m_CategoryTreeView.state.selectedIDs   = m_CategoryTreeViewState.selectedIDs;
                m_CategoryTreeViewState = m_CategoryTreeView.state;

                // Update the tree with the new collection.
                (m_CategoryTreeView.TreeModal as CategoryCollectionModal).ItemCollection = m_ItemCollection;
                m_CategoryTreeView.Reload();

                // The TreeViewState would have been reconstructed after deserialization so update the state within the tree.
                m_ItemTypeTreeView.state.expandedIDs   = m_ItemTypeTreeViewState.expandedIDs;
                m_ItemTypeTreeView.state.lastClickedID = m_ItemTypeTreeViewState.lastClickedID;
                m_ItemTypeTreeView.state.searchString  = m_ItemTypeTreeViewState.searchString;
                m_ItemTypeTreeView.state.selectedIDs   = m_ItemTypeTreeViewState.selectedIDs;
                m_ItemTypeTreeViewState = m_ItemTypeTreeView.state;

                // Update the tree with the new collection.
                (m_ItemTypeTreeView.TreeModal as ItemTypeCollectionModal).ItemCollection = m_ItemCollection;
                m_ItemTypeTreeView.Reload();
            }
        }
Exemple #4
0
        /// <summary>
        /// Initialize the manager after deserialization.
        /// </summary>
        public override void Initialize(MainManagerWindow mainManagerWindow)
        {
            base.Initialize(mainManagerWindow);

            // Find the state configuration.
            var stateConfiguration = ManagerUtility.FindStateConfiguration(m_MainManagerWindow);

            if (stateConfiguration != null)
            {
                if (m_AddStateConfiguration == null)
                {
                    m_AddStateConfiguration = stateConfiguration;
                }
                if (m_ExistingStateConfiguration == null)
                {
                    m_ExistingStateConfiguration = stateConfiguration;
                }
            }

            m_InvisibleShadowCaster = ManagerUtility.FindInvisibleShadowCaster(m_MainManagerWindow);
        }
Exemple #5
0
        /// <summary>
        /// Draws the controls for button and input setup.
        /// </summary>
        private void DrawProjectSetup()
        {
            // Show a warning if the button mappings or layers have not been updated.
            var serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]);
            var axisProperty     = serializedObject.FindProperty("m_Axes");
            var hasInputs        = UnityInputBuilder.FindAxisProperty(axisProperty, "Action", false) != null && UnityInputBuilder.FindAxisProperty(axisProperty, "Crouch", false) != null;

            var tagManager     = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
            var layersProperty = tagManager.FindProperty("layers");
            var hasLayers      = layersProperty.GetArrayElementAtIndex(LayerManager.Character).stringValue == "Character";

            if (!hasInputs || !hasLayers)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                EditorGUILayout.HelpBox("The default button mappings or layers have not been added. If you are just getting started you should update the button mappings and layers with the button below. " +
                                        "This can be changed layer.", MessageType.Warning);

                GUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Update Buttons and Layers", GUILayout.Width(170)))
                {
                    Utility.CharacterInputBuilder.UpdateInputManager();
                    UpdateLayers();
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndHorizontal();
                EditorGUILayout.EndVertical();
                GUILayout.Space(10);
            }

            ManagerUtility.DrawControlBox("Button Mappings", null, "Add the default button mappings to the Unity Input Manager. If you are using a custom button mapping or " +
                                          "an input integration then you do not need to update the Unity button mappings.", true, "Update Buttons",
                                          Utility.CharacterInputBuilder.UpdateInputManager, "The button mappings were successfully updated.");
            GUILayout.Space(10);

            ManagerUtility.DrawControlBox("Layers", null, "Update the project layers to the default character controller layers. The layers do not need to be updated " +
                                          "if you have already setup a custom set of layers.", true, "Update Layers", UpdateLayers, "The layers were successfully updated.");
        }
 /// <summary>
 /// Draws the ObjectManager.
 /// </summary>
 public override void OnGUI()
 {
     ManagerUtility.DrawControlBox("Object Builder", DrawObjectTypes, "Builds a new object with the specified type.",
                                   m_Name != null && (m_Object != null || !RequiresGameObject()) && m_CanBuild,
                                   "Build Object", BuildObject, string.Empty);
 }
Exemple #7
0
        /// <summary>
        /// Initialize the manager after deserialization.
        /// </summary>
        public override void Initialize(MainManagerWindow mainManagerWindow)
        {
            base.Initialize(mainManagerWindow);

            // Set the default perspective based on what asset is installed.
            if (m_Perspective == Perspective.None)
            {
#if FIRST_PERSON_CONTROLLER
                m_Perspective = Perspective.First;
#elif THIRD_PERSON_CONTROLLER
                m_Perspective = Perspective.Third;
#endif
            }

            // Get a list of the available view types.
            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
            for (int i = 0; i < assemblies.Length; ++i)
            {
                try {
                    var assemblyTypes = assemblies[i].GetTypes();
                    for (int j = 0; j < assemblyTypes.Length; ++j)
                    {
                        // Must derive from ViewType.
                        if (!typeof(UltimateCharacterController.Camera.ViewTypes.ViewType).IsAssignableFrom(assemblyTypes[j]))
                        {
                            continue;
                        }

                        // Ignore abstract classes.
                        if (assemblyTypes[j].IsAbstract)
                        {
                            continue;
                        }

                        if (assemblyTypes[j].FullName.Contains("FirstPersonController"))
                        {
                            m_FirstPersonViewTypes.Add(assemblyTypes[j]);
                        }
                        else if (assemblyTypes[j].FullName.Contains("ThirdPersonController"))
                        {
                            m_ThirdPersonViewTypes.Add(assemblyTypes[j]);
                        }
                    }
                } catch (Exception) {
                    continue;
                }
            }

            // Create an array of display names for the popup.
            if (m_FirstPersonViewTypes.Count > 0)
            {
                m_FirstPersonViewTypeStrings = new string[m_FirstPersonViewTypes.Count];
                for (int i = 0; i < m_FirstPersonViewTypes.Count; ++i)
                {
                    m_FirstPersonViewTypeStrings[i] = InspectorUtility.DisplayTypeName(m_FirstPersonViewTypes[i], true);
                }
            }
            if (m_ThirdPersonViewTypes.Count > 0)
            {
                m_ThirdPersonViewTypeStrings = new string[m_ThirdPersonViewTypes.Count];
                for (int i = 0; i < m_ThirdPersonViewTypes.Count; ++i)
                {
                    m_ThirdPersonViewTypeStrings[i] = InspectorUtility.DisplayTypeName(m_ThirdPersonViewTypes[i], true);
                }
            }

            // Find the state configuration.
            var stateConfiguration = ManagerUtility.FindStateConfiguration(m_MainManagerWindow);
            if (stateConfiguration != null)
            {
                if (m_StateConfiguration == null)
                {
                    m_StateConfiguration = stateConfiguration;
                }
            }
        }