public static void AddImpactManagerToScene()
        {
            GameObject    g             = new GameObject("Impact Manager");
            ImpactManager impactManager = g.AddComponent <ImpactManager>();

            Selection.activeGameObject = g;
        }
Esempio n. 2
0
 void Awake()
 {
     instance = this;
 }
        public override void OnInspectorGUI()
        {
            configurationManager = target as ImpactManager;
            serializedObject.Update();

            EditorGUILayout.Separator();

            EditorGUILayout.LabelField("General", EditorStyles.boldLabel);

            doProperty(physicsInteractionsLimit, new GUIContent("Physics Interactions Limit", "The maximum number of interactions generated by the built-in physics triggers that can be processed in a single fixed update. 0 = No limit."));
            doProperty(interactionResultBufferSize, new GUIContent("Interaction Result Buffer Size", "The size of the buffer array used to retrieve interaction results. This will be the maximum number of interaction results that can be produced by a single interaction."));
            doProperty(activeContinuousInteractions, new GUIContent("Max Active Continuous Interactions", "The maximum number of continuous interactions (i.e. sliding and rolling) that can be active at the same time."));
            doProperty(materialCompositionBufferSize, new GUIContent("Material Composition Buffer Size", "The size of the buffer array used to retrieve material composition results. This will be the maximum number of materials that can be returned when using material composition."));

            EditorGUILayout.Separator();

            doProperty(dontDestroyOnLoad, new GUIContent("Don't Destroy On Load", "Should the manager persist across scene loads?"));
            doProperty(setAsActiveInstance, new GUIContent("Set as Active Instance", "Should the manager be set as the active ImpactManager instance on Awake?"));

            ImpactEditorUtilities.Separator();

            EditorGUILayout.LabelField("Material Mapping", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(useMaterialMapping, new GUIContent("Use Material Mapping", "Use the Physics Material to Impact Material mapping feature?"));

            EditorGUILayout.HelpBox("Use Material Mapping to map from Physics Materials to Impact Materials so that you don't have to add Impact Object components to every object. This works best for static objects.", MessageType.Info);

            GUI.enabled = useMaterialMapping.boolValue;

            EditorGUILayout.Separator();

            //3D physic material mappings
            physicMaterialMappingFoldout = EditorGUILayout.Foldout(physicMaterialMappingFoldout, "Physic Material Mappings (3D Physics)");

            if (physicMaterialMappingFoldout)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                GUILayout.Space(2);

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("New"))
                {
                    physicMaterialMapping.arraySize++;
                }

                if (GUILayout.Button("Clear"))
                {
                    if (EditorUtility.DisplayDialog("Clear All Physic Material Mappings", "Are you sure you want to remove all Physic Material  Mappings? This cannot be undone.", "Yes", "No"))
                    {
                        physicMaterialMapping.ClearArray();
                    }
                }

                EditorGUILayout.EndHorizontal();

                if (physicMaterialMapping.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("No Physic Material mappings have been created.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.Separator();

                    for (int i = 0; i < physicMaterialMapping.arraySize; i++)
                    {
                        SerializedProperty mapping        = physicMaterialMapping.GetArrayElementAtIndex(i);
                        SerializedProperty physicMaterial = mapping.FindPropertyRelative("PhysicMaterial");
                        SerializedProperty impactMaterial = mapping.FindPropertyRelative("ImpactMaterial");

                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.PropertyField(physicMaterial, new GUIContent());
                        EditorGUILayout.LabelField("→", GUILayout.Width(20));
                        EditorGUILayout.PropertyField(impactMaterial, new GUIContent());

                        Color originalColor = GUI.color;
                        GUI.color = warningColor;
                        if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            physicMaterialMapping.DeleteArrayElementAtIndex(i);
                        }
                        GUI.color = originalColor;

                        EditorGUILayout.EndHorizontal();
                    }
                }

                GUILayout.Space(2);

                EditorGUILayout.EndVertical();
            }

            //2D physic material mappings
            physicsMaterial2DMappingFoldout = EditorGUILayout.Foldout(physicsMaterial2DMappingFoldout, "Physics Material 2D Mappings (2D Physics)");

            if (physicsMaterial2DMappingFoldout)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);

                GUILayout.Space(2);

                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("New"))
                {
                    physicsMaterial2DMapping.arraySize++;
                }

                if (GUILayout.Button("Clear"))
                {
                    if (EditorUtility.DisplayDialog("Clear All Physic Material Mappings", "Are you sure you want to remove all Physic Material  Mappings? This cannot be undone.", "Yes", "No"))
                    {
                        physicsMaterial2DMapping.ClearArray();
                    }
                }

                EditorGUILayout.EndHorizontal();

                if (physicsMaterial2DMapping.arraySize == 0)
                {
                    EditorGUILayout.HelpBox("No Physics Material 2D mappings have been created.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.Separator();

                    for (int i = 0; i < physicsMaterial2DMapping.arraySize; i++)
                    {
                        SerializedProperty mapping        = physicsMaterial2DMapping.GetArrayElementAtIndex(i);
                        SerializedProperty physicMaterial = mapping.FindPropertyRelative("PhysicsMaterial2D");
                        SerializedProperty impactMaterial = mapping.FindPropertyRelative("ImpactMaterial");

                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.PropertyField(physicMaterial, new GUIContent());
                        EditorGUILayout.LabelField("→", GUILayout.Width(20));
                        EditorGUILayout.PropertyField(impactMaterial, new GUIContent());

                        Color originalColor = GUI.color;
                        GUI.color = warningColor;
                        if (GUILayout.Button(new GUIContent("X", "Remove"), GUILayout.Width(20), GUILayout.Height(15)))
                        {
                            physicsMaterial2DMapping.DeleteArrayElementAtIndex(i);
                        }
                        GUI.color = originalColor;

                        EditorGUILayout.EndHorizontal();
                    }
                }

                GUILayout.Space(2);

                EditorGUILayout.EndVertical();
            }

            GUI.enabled = true;

            serializedObject.ApplyModifiedProperties();
        }
Esempio n. 4
0
 // Use this for initialization
 void Awake()
 {
     Instance = this;
 }
Esempio n. 5
0
 private void Awake()
 {
     Instance = this;
 }
Esempio n. 6
0
 // Use this for initialization
 protected virtual void Start()
 {
     impMan = GameObject.FindGameObjectWithTag("Manager").GetComponent<ImpactManager>();
     gameMan = impMan.GetComponent<GameManager>();
     tutMan = impMan.GetComponent<TutorialManager>();
     mTrans = transform;
 }