void OnEnable() { ProCamera2DEditorHelper.AssignProCamera2D(target as BasePC2D); _proCamera2DParallax = (ProCamera2DParallax)target; _proCamera2D = _proCamera2DParallax.ProCamera2D; _script = MonoScript.FromMonoBehaviour(_proCamera2DParallax); // Parallax layers List _parallaxLayersList = new ReorderableList(serializedObject, serializedObject.FindProperty("ParallaxLayers"), false, true, true, true); // Draw element callback _parallaxLayersList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.y += 2; var element = _parallaxLayersList.serializedProperty.GetArrayElementAtIndex(index); #if UNITY_5 EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 65, 10), new GUIContent("Camera", "The parallax camera"), EditorStyles.boldLabel); #else EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 65, 10), new GUIContent("Camera", "The parallax camera")); #endif EditorGUI.PropertyField(new Rect( rect.x + 65, rect.y, 80, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("ParallaxCamera"), GUIContent.none); // Speed slider #if UNITY_5 EditorGUI.PrefixLabel(new Rect(rect.x + 170, rect.y, 65, 10), new GUIContent("Speed", "The relative speed at which the camera should move in comparison to the main camera."), EditorStyles.boldLabel); #else EditorGUI.PrefixLabel(new Rect(rect.x + 170, rect.y, 65, 10), new GUIContent("Speed", "The relative speed at which the camera should move in comparison to the main camera.")); #endif EditorGUI.PropertyField(new Rect( rect.x + 210, rect.y, rect.width - 210, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Speed"), GUIContent.none); // Layer mask #if UNITY_5 EditorGUI.PrefixLabel(new Rect(rect.x, rect.y + 25, 65, 10), new GUIContent("Culling Mask", "Which layers should this camera render?"), EditorStyles.boldLabel); #else EditorGUI.PrefixLabel(new Rect(rect.x, rect.y + 25, 65, 10), new GUIContent("Culling Mask", "Which layers should this camera render?")); #endif EditorGUI.PropertyField(new Rect( rect.x + 85, rect.y + 25, rect.width - 85, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("LayerMask"), GUIContent.none); }; // Draw header callback _parallaxLayersList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Parallax layers"); // Add element callback _parallaxLayersList.onAddCallback = list => AddParallaxLayer(); // Remove element callback _parallaxLayersList.onRemoveCallback = list => { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete this layer?", "Yes", "No")) { var cam = list.serializedProperty.GetArrayElementAtIndex(list.index).FindPropertyRelative("ParallaxCamera").objectReferenceValue as Camera; if (cam != null) DestroyImmediate(cam.gameObject); ReorderableList.defaultBehaviours.DoRemoveButton(list); } }; // Select element callback _parallaxLayersList.onSelectCallback = list => { EditorGUIUtility.PingObject(list.serializedProperty.GetArrayElementAtIndex(list.index).FindPropertyRelative("ParallaxCamera").objectReferenceValue as Camera); }; _parallaxLayersList.elementHeight = 65; _parallaxLayersList.headerHeight = 18; _parallaxLayersList.draggable = true; }
void OnEnable() { ProCamera2DEditorHelper.AssignProCamera2D(target as BasePC2D); _proCamera2DParallax = (ProCamera2DParallax)target; _proCamera2D = _proCamera2DParallax.ProCamera2D; _script = MonoScript.FromMonoBehaviour(_proCamera2DParallax); // Parallax layers List _parallaxLayersList = new ReorderableList(serializedObject, serializedObject.FindProperty("ParallaxLayers"), false, true, true, true); // Draw element callback _parallaxLayersList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.y += 2; var element = _parallaxLayersList.serializedProperty.GetArrayElementAtIndex(index); #if UNITY_5 EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 65, 10), new GUIContent("Camera", "The parallax camera"), EditorStyles.boldLabel); #else EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 65, 10), new GUIContent("Camera", "The parallax camera")); #endif EditorGUI.PropertyField(new Rect( rect.x + 65, rect.y, 80, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("ParallaxCamera"), GUIContent.none); // Speed slider #if UNITY_5 EditorGUI.PrefixLabel(new Rect(rect.x + 170, rect.y, 65, 10), new GUIContent("Speed", "The relative speed at which the camera should move in comparison to the main camera."), EditorStyles.boldLabel); #else EditorGUI.PrefixLabel(new Rect(rect.x + 170, rect.y, 65, 10), new GUIContent("Speed", "The relative speed at which the camera should move in comparison to the main camera.")); #endif EditorGUI.PropertyField(new Rect( rect.x + 210, rect.y, rect.width - 210, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Speed"), GUIContent.none); // Layer mask #if UNITY_5 EditorGUI.PrefixLabel(new Rect(rect.x, rect.y + 25, 65, 10), new GUIContent("Culling Mask", "Which layers should this camera render?"), EditorStyles.boldLabel); #else EditorGUI.PrefixLabel(new Rect(rect.x, rect.y + 25, 65, 10), new GUIContent("Culling Mask", "Which layers should this camera render?")); #endif EditorGUI.PropertyField(new Rect( rect.x + 85, rect.y + 25, rect.width - 85, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("LayerMask"), GUIContent.none); }; // Draw header callback _parallaxLayersList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Parallax layers"); // Add element callback _parallaxLayersList.onAddCallback = list => AddParallaxLayer(); // Remove element callback _parallaxLayersList.onRemoveCallback = list => { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete this layer?", "Yes", "No")) { var cam = list.serializedProperty.GetArrayElementAtIndex(list.index).FindPropertyRelative("ParallaxCamera").objectReferenceValue as Camera; if (cam != null) { DestroyImmediate(cam.gameObject); } ReorderableList.defaultBehaviours.DoRemoveButton(list); } }; // Select element callback _parallaxLayersList.onSelectCallback = list => { EditorGUIUtility.PingObject(list.serializedProperty.GetArrayElementAtIndex(list.index).FindPropertyRelative("ParallaxCamera").objectReferenceValue as Camera); }; _parallaxLayersList.elementHeight = 65; _parallaxLayersList.headerHeight = 18; _parallaxLayersList.draggable = true; }
void OnEnable() { if (target == null) { return; } _proCamera2DParallax = (ProCamera2DParallax)target; _proCamera2D = _proCamera2DParallax.ProCamera2D; _script = MonoScript.FromMonoBehaviour(_proCamera2DParallax); // Parallax layers List _parallaxLayersList = new ReorderableList(serializedObject, serializedObject.FindProperty("ParallaxLayers"), false, true, true, true); // Draw element callback _parallaxLayersList.drawElementCallback = (rect, index, isActive, isFocused) => { rect.y += 2; var element = _parallaxLayersList.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PrefixLabel(new Rect(rect.x, rect.y, 65, 10), new GUIContent("Camera", "The parallax camera")); EditorGUI.PropertyField(new Rect( rect.x + 65, rect.y, 80, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("ParallaxCamera"), GUIContent.none); // Speed slider EditorGUI.LabelField(new Rect(rect.x + 170, rect.y, 65, 20), new GUIContent(_proCamera2DParallax.UseIndependentAxisSpeeds ? "SpeedX" : "Speed", "The relative speed at which the camera should move in comparison to the main camera.")); if (_proCamera2DParallax.UseIndependentAxisSpeeds) { EditorGUI.LabelField(new Rect(rect.x + 170, rect.y + 15, 65, 20), new GUIContent("SpeedY", "The relative speed at which the camera should move in comparison to the main camera.")); } if (_proCamera2DParallax.UseIndependentAxisSpeeds) { EditorGUI.PropertyField(new Rect( rect.x + 215, rect.y, rect.width - 215, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("SpeedX"), GUIContent.none); EditorGUI.PropertyField(new Rect( rect.x + 215, rect.y + 15, rect.width - 215, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("SpeedY"), GUIContent.none); } else { EditorGUI.PropertyField(new Rect( rect.x + 210, rect.y, rect.width - 210, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("Speed"), GUIContent.none); } if (_proCamera2DParallax.UseIndependentAxisSpeeds) { rect.y += 10; } // Layer mask EditorGUI.PrefixLabel(new Rect(rect.x, rect.y + 25, 65, 10), new GUIContent("Culling Mask", "Which layers should this camera render?")); EditorGUI.PropertyField(new Rect( rect.x + 85, rect.y + 25, rect.width - 85, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("LayerMask"), GUIContent.none); }; // Draw header callback _parallaxLayersList.drawHeaderCallback = rect => EditorGUI.LabelField(rect, "Parallax layers"); // Add element callback _parallaxLayersList.onAddCallback = list => AddParallaxLayer(); // Remove element callback _parallaxLayersList.onRemoveCallback = list => { if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to delete this layer?", "Yes", "No")) { var cam = list.serializedProperty.GetArrayElementAtIndex(list.index).FindPropertyRelative("ParallaxCamera").objectReferenceValue as Camera; if (cam != null) { DestroyImmediate(cam.gameObject); } ReorderableList.defaultBehaviours.DoRemoveButton(list); } }; // Select element callback _parallaxLayersList.onSelectCallback = list => { EditorGUIUtility.PingObject(list.serializedProperty.GetArrayElementAtIndex(list.index).FindPropertyRelative("ParallaxCamera").objectReferenceValue as Camera); }; _parallaxLayersList.onReorderCallback = list => { if (_proCamera2DParallax.ParallaxLayers[0].ParallaxCamera.clearFlags != CameraClearFlags.SolidColor && _proCamera2DParallax.ParallaxLayers[0].ParallaxCamera.clearFlags != CameraClearFlags.Skybox) { _proCamera2DParallax.ParallaxLayers[0].ParallaxCamera.clearFlags = CameraClearFlags.SolidColor; } }; _parallaxLayersList.elementHeight = 70; _parallaxLayersList.headerHeight = 18; _parallaxLayersList.draggable = true; }