added platfrom break effect
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
<!-- UNITY CODE ASSIST INSTRUCTIONS START -->
|
<!-- UNITY CODE ASSIST INSTRUCTIONS START -->
|
||||||
- Project name: Ultimate-HelixJump
|
- Project name: Ultimate-HelixJump
|
||||||
- Unity version: Unity 6000.3.0f1
|
- Unity version: Unity 6000.3.0f1
|
||||||
|
- Active game object:
|
||||||
|
- Name: GameLifetimeScope
|
||||||
|
- Tag: Untagged
|
||||||
|
- Layer: Default
|
||||||
<!-- UNITY CODE ASSIST INSTRUCTIONS END -->
|
<!-- UNITY CODE ASSIST INSTRUCTIONS END -->
|
||||||
@@ -129,8 +129,8 @@ Material:
|
|||||||
- _XRMotionVectorsPass: 1
|
- _XRMotionVectorsPass: 1
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0, g: 1, b: 0.91027117, a: 1}
|
- _BaseColor: {r: 0, g: 1, b: 0.98041606, a: 0}
|
||||||
- _Color: {r: 0, g: 1, b: 0.91027117, a: 1}
|
- _Color: {r: 0, g: 1, b: 0.980416, a: 0}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|||||||
@@ -8,18 +8,19 @@ Material:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: PlayerDeadParticles
|
m_Name: PlayerDeadParticles
|
||||||
m_Shader: {fileID: 4800000, guid: 13c02b14c4d048fa9653293d54f6e0e1, type: 3}
|
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_Parent: {fileID: 0}
|
||||||
m_ModifiedSerializedProperties: 0
|
m_ModifiedSerializedProperties: 0
|
||||||
m_ValidKeywords: []
|
m_ValidKeywords:
|
||||||
m_InvalidKeywords:
|
|
||||||
- _ALPHAPREMULTIPLY_ON
|
- _ALPHAPREMULTIPLY_ON
|
||||||
- _SURFACE_TYPE_TRANSPARENT
|
- _SURFACE_TYPE_TRANSPARENT
|
||||||
|
m_InvalidKeywords: []
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: 3000
|
||||||
stringTagMap: {}
|
stringTagMap:
|
||||||
|
RenderType: Transparent
|
||||||
disabledShaderPasses:
|
disabledShaderPasses:
|
||||||
- MOTIONVECTORS
|
- MOTIONVECTORS
|
||||||
- DepthOnly
|
- DepthOnly
|
||||||
@@ -33,7 +34,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _BaseMap:
|
- _BaseMap:
|
||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 2800000, guid: 80b74a073fa3027458f3b3ff5346f10b, type: 3}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _BumpMap:
|
- _BumpMap:
|
||||||
@@ -57,7 +58,7 @@ Material:
|
|||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MainTex:
|
- _MainTex:
|
||||||
m_Texture: {fileID: 10912, guid: 0000000000000000f000000000000000, type: 0}
|
m_Texture: {fileID: 2800000, guid: 80b74a073fa3027458f3b3ff5346f10b, type: 3}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
- _MetallicGlossMap:
|
- _MetallicGlossMap:
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ Material:
|
|||||||
- _XRMotionVectorsPass: 1
|
- _XRMotionVectorsPass: 1
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0.8584906, g: 0.09138395, b: 0.08503916, a: 1}
|
- _BaseColor: {r: 0.8113208, g: 0.049750824, b: 0.049750824, a: 0}
|
||||||
- _Color: {r: 0.8584906, g: 0.09138393, b: 0.08503913, a: 1}
|
- _Color: {r: 0.17342025, g: 0.75471693, b: 0.07475967, a: 0}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ Material:
|
|||||||
- _XRMotionVectorsPass: 1
|
- _XRMotionVectorsPass: 1
|
||||||
- _ZWrite: 1
|
- _ZWrite: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
- _BaseColor: {r: 0, g: 0, b: 0, a: 1}
|
- _BaseColor: {r: 0.8113208, g: 0.53379685, b: 0.04209684, a: 1}
|
||||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
- _Color: {r: 0.8113207, g: 0.53379685, b: 0.042096816, a: 1}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||||
m_BuildTextureStacks: []
|
m_BuildTextureStacks: []
|
||||||
|
|||||||
8
Assets/MeshCombiner.meta
Normal file
8
Assets/MeshCombiner.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e038eb1e2eab0dd48b3db937423ef8df
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/MeshCombiner/Editor.meta
Normal file
8
Assets/MeshCombiner/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 303657b881c5c104fabb7c2d58e364ae
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
144
Assets/MeshCombiner/Editor/MeshCombinerEditor.cs
Normal file
144
Assets/MeshCombiner/Editor/MeshCombinerEditor.cs
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[CustomEditor(typeof(MeshCombiner))]
|
||||||
|
public class MeshCombinerEditor : Editor
|
||||||
|
{
|
||||||
|
public override void OnInspectorGUI()
|
||||||
|
{
|
||||||
|
MeshCombiner meshCombiner = (MeshCombiner)target;
|
||||||
|
Mesh mesh = meshCombiner.GetComponent<MeshFilter>().sharedMesh;
|
||||||
|
|
||||||
|
#region Script:
|
||||||
|
GUI.enabled = false;
|
||||||
|
EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour((MeshCombiner)target), typeof(MeshCombiner), false);
|
||||||
|
GUI.enabled = true;
|
||||||
|
#endregion Script.
|
||||||
|
|
||||||
|
#region MeshFiltersToSkip array:
|
||||||
|
SerializedProperty meshFiltersToSkip = serializedObject.FindProperty("meshFiltersToSkip");
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
EditorGUILayout.PropertyField(meshFiltersToSkip, true);
|
||||||
|
if(EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
}
|
||||||
|
#endregion MeshFiltersToSkip array.
|
||||||
|
|
||||||
|
#region Button which combine Meshes into one Mesh & Toggles with combine options:
|
||||||
|
// Button:
|
||||||
|
if(GUILayout.Button("Combine Meshes"))
|
||||||
|
{
|
||||||
|
meshCombiner.CombineMeshes(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toggles:
|
||||||
|
meshCombiner.CreateMultiMaterialMesh = GUILayout.Toggle(meshCombiner.CreateMultiMaterialMesh, "Create Multi-Material Mesh");
|
||||||
|
meshCombiner.CombineInactiveChildren = GUILayout.Toggle(meshCombiner.CombineInactiveChildren, "Combine Inactive Children");
|
||||||
|
|
||||||
|
meshCombiner.DeactivateCombinedChildren = GUILayout.Toggle(meshCombiner.DeactivateCombinedChildren, "Deactivate Combined Children");
|
||||||
|
meshCombiner.DeactivateCombinedChildrenMeshRenderers = GUILayout.Toggle(meshCombiner.DeactivateCombinedChildrenMeshRenderers,
|
||||||
|
"Deactivate Combined Children's MeshRenderers");
|
||||||
|
|
||||||
|
meshCombiner.GenerateUVMap = GUILayout.Toggle(meshCombiner.GenerateUVMap, new GUIContent("Generate UV Map", "It is a slow operation that "+
|
||||||
|
"generates a UV map (required for the lightmap).\n\nCan be used only in the Editor."));
|
||||||
|
|
||||||
|
// The last (6) "Destroy Combined Children" Toggle:
|
||||||
|
GUIStyle style = new GUIStyle(EditorStyles.toggle);
|
||||||
|
if(meshCombiner.DestroyCombinedChildren)
|
||||||
|
{
|
||||||
|
style.onNormal.textColor = new Color(1, 0.15f, 0);
|
||||||
|
}
|
||||||
|
meshCombiner.DestroyCombinedChildren = GUILayout.Toggle(meshCombiner.DestroyCombinedChildren,
|
||||||
|
new GUIContent("Destroy Combined Children", "In the editor this operation can NOT be undone!\n\n"+
|
||||||
|
"If you want to bring back destroyed GameObjects, you have to load again the scene without saving."), style);
|
||||||
|
#endregion Button which combine Meshes into one Mesh & Toggles with combine options.
|
||||||
|
|
||||||
|
#region Path to the folder where combined Meshes will be saved:
|
||||||
|
// Create Labels:
|
||||||
|
GUILayout.Label("");
|
||||||
|
GUILayout.Label(new GUIContent("Folder path:", "Folder path to save combined Mesh."));
|
||||||
|
|
||||||
|
// Create style wherein text color will be red if folder path is not valid:
|
||||||
|
style = new GUIStyle(EditorStyles.textField);
|
||||||
|
bool isValidPath = IsValidPath(meshCombiner.FolderPath);
|
||||||
|
if(!isValidPath)
|
||||||
|
{
|
||||||
|
style.normal.textColor = Color.red;
|
||||||
|
style.focused.textColor = Color.red;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create TextField with custom style:
|
||||||
|
meshCombiner.FolderPath = EditorGUILayout.TextField(meshCombiner.FolderPath, style);
|
||||||
|
#endregion Path to the folder where combined Meshes will be saved.
|
||||||
|
|
||||||
|
#region Button which save/show combined Mesh:
|
||||||
|
bool meshIsSaved = (mesh != null && AssetDatabase.Contains(mesh));
|
||||||
|
GUI.enabled = (mesh != null && (isValidPath || meshIsSaved)); // Valid path is required for not saved Mesh.
|
||||||
|
string saveMeshButtonText = (meshIsSaved) ? "Show Saved Combined Mesh" : "Save Combined Mesh";
|
||||||
|
|
||||||
|
if(GUILayout.Button(saveMeshButtonText))
|
||||||
|
{
|
||||||
|
meshCombiner.FolderPath = SaveCombinedMesh(mesh, meshCombiner.FolderPath);
|
||||||
|
}
|
||||||
|
GUI.enabled = true;
|
||||||
|
#endregion Button which save/show combined Mesh.
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsValidPath(string folderPath)
|
||||||
|
{
|
||||||
|
string pattern = "[:*?\"<>|]"; // Prohibited characters.
|
||||||
|
Regex regex = new Regex(pattern);
|
||||||
|
return (!regex.IsMatch(folderPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string SaveCombinedMesh(Mesh mesh, string folderPath)
|
||||||
|
{
|
||||||
|
bool meshIsSaved = AssetDatabase.Contains(mesh); // If is saved then only show it in the project view.
|
||||||
|
|
||||||
|
#region Create directories if Mesh and path doesn't exists:
|
||||||
|
folderPath = folderPath.Replace('\\', '/');
|
||||||
|
if(!meshIsSaved && !AssetDatabase.IsValidFolder("Assets/"+folderPath))
|
||||||
|
{
|
||||||
|
string[] folderNames = folderPath.Split('/');
|
||||||
|
folderNames = folderNames.Where((folderName) => !folderName.Equals("")).ToArray();
|
||||||
|
folderNames = folderNames.Where((folderName) => !folderName.Equals(" ")).ToArray();
|
||||||
|
|
||||||
|
folderPath = "/"; // Reset folder path.
|
||||||
|
for(int i = 0; i < folderNames.Length; i++)
|
||||||
|
{
|
||||||
|
folderNames[i] = folderNames[i].Trim();
|
||||||
|
if(!AssetDatabase.IsValidFolder("Assets"+folderPath+folderNames[i]))
|
||||||
|
{
|
||||||
|
string folderPathWithoutSlash = folderPath.Substring(0, folderPath.Length-1); // Delete last "/" character.
|
||||||
|
AssetDatabase.CreateFolder("Assets"+folderPathWithoutSlash, folderNames[i]);
|
||||||
|
}
|
||||||
|
folderPath += folderNames[i]+"/";
|
||||||
|
}
|
||||||
|
folderPath = folderPath.Substring(1, folderPath.Length-2); // Delete first and last "/" character.
|
||||||
|
}
|
||||||
|
#endregion Create directories if Mesh and path doesn't exists.
|
||||||
|
|
||||||
|
#region Save Mesh:
|
||||||
|
if(!meshIsSaved)
|
||||||
|
{
|
||||||
|
string meshPath = "Assets/"+folderPath+"/"+mesh.name+".asset";
|
||||||
|
int assetNumber = 1;
|
||||||
|
while(AssetDatabase.LoadAssetAtPath(meshPath, typeof(Mesh)) != null) // If Mesh with same name exists, change name.
|
||||||
|
{
|
||||||
|
meshPath = "Assets/"+folderPath+"/"+mesh.name+" ("+assetNumber+").asset";
|
||||||
|
assetNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
|
AssetDatabase.CreateAsset(mesh, meshPath);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
Debug.Log("<color=#ff9900><b>Mesh \""+mesh.name+"\" was saved in the \""+folderPath+"\" folder.</b></color>"); // Show info about saved mesh.
|
||||||
|
}
|
||||||
|
#endregion Save Mesh.
|
||||||
|
|
||||||
|
EditorGUIUtility.PingObject(mesh); // Show Mesh in the project view.
|
||||||
|
return folderPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Assets/MeshCombiner/Editor/MeshCombinerEditor.cs.meta
Normal file
18
Assets/MeshCombiner/Editor/MeshCombinerEditor.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e2ae2996f91d32944a854e57dfc5a7ff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
AssetOrigin:
|
||||||
|
serializedVersion: 1
|
||||||
|
productId: 157192
|
||||||
|
packageName: Mesh Combiner
|
||||||
|
packageVersion: 1.2
|
||||||
|
assetPath: Assets/MeshCombiner/Editor/MeshCombinerEditor.cs
|
||||||
|
uploadId: 399985
|
||||||
8
Assets/MeshCombiner/Scripts.meta
Normal file
8
Assets/MeshCombiner/Scripts.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a2a7540ec4650c74fbbf276d68fcb924
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
396
Assets/MeshCombiner/Scripts/MeshCombiner.cs
Normal file
396
Assets/MeshCombiner/Scripts/MeshCombiner.cs
Normal file
@@ -0,0 +1,396 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(MeshFilter))]
|
||||||
|
[RequireComponent(typeof(MeshRenderer))]
|
||||||
|
public class MeshCombiner : MonoBehaviour
|
||||||
|
{
|
||||||
|
private const int Mesh16BitBufferVertexLimit = 65535;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private bool createMultiMaterialMesh = false, combineInactiveChildren = false, deactivateCombinedChildren = true,
|
||||||
|
deactivateCombinedChildrenMeshRenderers = false, generateUVMap = false, destroyCombinedChildren = false;
|
||||||
|
[SerializeField]
|
||||||
|
private string folderPath = "Prefabs/CombinedMeshes";
|
||||||
|
[SerializeField]
|
||||||
|
[Tooltip("MeshFilters with Meshes which we don't want to combine into one Mesh.")]
|
||||||
|
private MeshFilter[] meshFiltersToSkip = new MeshFilter[0];
|
||||||
|
|
||||||
|
public bool CreateMultiMaterialMesh { get { return createMultiMaterialMesh; } set { createMultiMaterialMesh = value; } }
|
||||||
|
public bool CombineInactiveChildren { get { return combineInactiveChildren; } set { combineInactiveChildren = value; } }
|
||||||
|
public bool DeactivateCombinedChildren
|
||||||
|
{
|
||||||
|
get { return deactivateCombinedChildren; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
deactivateCombinedChildren = value;
|
||||||
|
CheckDeactivateCombinedChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool DeactivateCombinedChildrenMeshRenderers
|
||||||
|
{
|
||||||
|
get { return deactivateCombinedChildrenMeshRenderers; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
deactivateCombinedChildrenMeshRenderers = value;
|
||||||
|
CheckDeactivateCombinedChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool GenerateUVMap { get { return generateUVMap; } set { generateUVMap = value; } }
|
||||||
|
public bool DestroyCombinedChildren
|
||||||
|
{
|
||||||
|
get { return destroyCombinedChildren; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
destroyCombinedChildren = value;
|
||||||
|
CheckDestroyCombinedChildren();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string FolderPath { get { return folderPath; } set { folderPath = value; } }
|
||||||
|
|
||||||
|
|
||||||
|
private void CheckDeactivateCombinedChildren()
|
||||||
|
{
|
||||||
|
if(deactivateCombinedChildren || deactivateCombinedChildrenMeshRenderers)
|
||||||
|
{
|
||||||
|
destroyCombinedChildren = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckDestroyCombinedChildren()
|
||||||
|
{
|
||||||
|
if(destroyCombinedChildren)
|
||||||
|
{
|
||||||
|
deactivateCombinedChildren = false;
|
||||||
|
deactivateCombinedChildrenMeshRenderers = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Combine children's Meshes into one Mesh. Set 'showCreatedMeshInfo' to true if want to show info about created Mesh in the console.
|
||||||
|
/// </summary>
|
||||||
|
public void CombineMeshes(bool showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
#region Save our parent scale and our Transform and reset it temporarily:
|
||||||
|
// When we are unparenting and get parent again then sometimes scale is a little bit different so save scale before unparenting:
|
||||||
|
Vector3 oldScaleAsChild = transform.localScale;
|
||||||
|
|
||||||
|
// If we have parent then his scale will affect to our new combined Mesh scale so unparent us:
|
||||||
|
int positionInParentHierarchy = transform.GetSiblingIndex();
|
||||||
|
Transform parent = transform.parent;
|
||||||
|
transform.parent = null;
|
||||||
|
|
||||||
|
// Thanks to this the new combined Mesh will have same position and scale in the world space like its children:
|
||||||
|
Quaternion oldRotation = transform.rotation;
|
||||||
|
Vector3 oldPosition = transform.position;
|
||||||
|
Vector3 oldScale = transform.localScale;
|
||||||
|
transform.rotation = Quaternion.identity;
|
||||||
|
transform.position = Vector3.zero;
|
||||||
|
transform.localScale = Vector3.one;
|
||||||
|
#endregion Save Transform and reset it temporarily.
|
||||||
|
|
||||||
|
#region Combine Meshes into one Mesh:
|
||||||
|
if(!createMultiMaterialMesh)
|
||||||
|
{
|
||||||
|
CombineMeshesWithSingleMaterial(showCreatedMeshInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CombineMeshesWithMutliMaterial(showCreatedMeshInfo);
|
||||||
|
}
|
||||||
|
#endregion Combine Meshes into one Mesh.
|
||||||
|
|
||||||
|
#region Set old Transform values:
|
||||||
|
// Bring back the Transform values:
|
||||||
|
transform.rotation = oldRotation;
|
||||||
|
transform.position = oldPosition;
|
||||||
|
transform.localScale = oldScale;
|
||||||
|
|
||||||
|
// Get back parent and same hierarchy position:
|
||||||
|
transform.parent = parent;
|
||||||
|
transform.SetSiblingIndex(positionInParentHierarchy);
|
||||||
|
|
||||||
|
// Set back the scale value as child:
|
||||||
|
transform.localScale = oldScaleAsChild;
|
||||||
|
#endregion Set old Transform values.
|
||||||
|
}
|
||||||
|
|
||||||
|
private MeshFilter[] GetMeshFiltersToCombine()
|
||||||
|
{
|
||||||
|
// Get all MeshFilters belongs to this GameObject and its children:
|
||||||
|
MeshFilter[] meshFilters = GetComponentsInChildren<MeshFilter>(combineInactiveChildren);
|
||||||
|
|
||||||
|
// Delete first MeshFilter belongs to this GameObject in meshFiltersToSkip array:
|
||||||
|
meshFiltersToSkip = meshFiltersToSkip.Where((meshFilter) => meshFilter != meshFilters[0]).ToArray();
|
||||||
|
|
||||||
|
// Delete null values in meshFiltersToSkip array:
|
||||||
|
meshFiltersToSkip = meshFiltersToSkip.Where((meshFilter) => meshFilter != null).ToArray();
|
||||||
|
|
||||||
|
for(int i = 0; i < meshFiltersToSkip.Length; i++)
|
||||||
|
{
|
||||||
|
meshFilters = meshFilters.Where((meshFilter) => meshFilter != meshFiltersToSkip[i]).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return meshFilters;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CombineMeshesWithSingleMaterial(bool showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
// Get all MeshFilters belongs to this GameObject and its children:
|
||||||
|
MeshFilter[] meshFilters = GetMeshFiltersToCombine();
|
||||||
|
|
||||||
|
// First MeshFilter belongs to this GameObject so we don't need it:
|
||||||
|
CombineInstance[] combineInstances = new CombineInstance[meshFilters.Length-1];
|
||||||
|
|
||||||
|
// If it will be over 65535 then use the 32 bit index buffer:
|
||||||
|
long verticesLength = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < meshFilters.Length-1; i++) // Skip first MeshFilter belongs to this GameObject in this loop.
|
||||||
|
{
|
||||||
|
combineInstances[i].subMeshIndex = 0;
|
||||||
|
combineInstances[i].mesh = meshFilters[i+1].sharedMesh;
|
||||||
|
combineInstances[i].transform = meshFilters[i+1].transform.localToWorldMatrix;
|
||||||
|
verticesLength += combineInstances[i].mesh.vertices.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set Material from child:
|
||||||
|
MeshRenderer[] meshRenderers = GetComponentsInChildren<MeshRenderer>(combineInactiveChildren);
|
||||||
|
if(meshRenderers.Length >= 2)
|
||||||
|
{
|
||||||
|
meshRenderers[0].sharedMaterials = new Material[1];
|
||||||
|
meshRenderers[0].sharedMaterial = meshRenderers[1].sharedMaterial;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meshRenderers[0].sharedMaterials = new Material[0]; // Reset the MeshRenderer's Materials array.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create Mesh from combineInstances:
|
||||||
|
Mesh combinedMesh = new Mesh();
|
||||||
|
combinedMesh.name = name;
|
||||||
|
|
||||||
|
#if UNITY_2017_3_OR_NEWER
|
||||||
|
if(verticesLength > Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
combinedMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; // Only works on Unity 2017.3 or higher.
|
||||||
|
}
|
||||||
|
|
||||||
|
combinedMesh.CombineMeshes(combineInstances);
|
||||||
|
GenerateUV(combinedMesh);
|
||||||
|
meshFilters[0].sharedMesh = combinedMesh;
|
||||||
|
DeactivateCombinedGameObjects(meshFilters);
|
||||||
|
|
||||||
|
if(showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
if(verticesLength <= Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
Debug.Log("<color=#00cc00><b>Mesh \""+name+"\" was created from "+combineInstances.Length+" children meshes and has "+verticesLength
|
||||||
|
+" vertices.</b></color>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("<color=#ff3300><b>Mesh \""+name+"\" was created from "+combineInstances.Length+" children meshes and has "+verticesLength
|
||||||
|
+" vertices. Some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices.</b></color>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(verticesLength <= Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
combinedMesh.CombineMeshes(combineInstances);
|
||||||
|
GenerateUV(combinedMesh);
|
||||||
|
meshFilters[0].sharedMesh = combinedMesh;
|
||||||
|
DeactivateCombinedGameObjects(meshFilters);
|
||||||
|
|
||||||
|
if(showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
Debug.Log("<color=#00cc00><b>Mesh \""+name+"\" was created from "+combineInstances.Length+" children meshes and has "+verticesLength
|
||||||
|
+" vertices.</b></color>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
Debug.Log("<color=red><b>The mesh vertex limit is 65535! The created mesh had "+verticesLength+" vertices. Upgrade Unity version to"
|
||||||
|
+" 2017.3 or higher to avoid this limit (some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices).</b></color>");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CombineMeshesWithMutliMaterial(bool showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
#region Get MeshFilters, MeshRenderers and unique Materials from all children:
|
||||||
|
MeshFilter[] meshFilters = GetMeshFiltersToCombine();
|
||||||
|
MeshRenderer[] meshRenderers = new MeshRenderer[meshFilters.Length];
|
||||||
|
meshRenderers[0] = GetComponent<MeshRenderer>(); // Our (parent) MeshRenderer.
|
||||||
|
|
||||||
|
List<Material> uniqueMaterialsList = new List<Material>();
|
||||||
|
for(int i = 0; i < meshFilters.Length-1; i++)
|
||||||
|
{
|
||||||
|
meshRenderers[i+1] = meshFilters[i+1].GetComponent<MeshRenderer>();
|
||||||
|
if(meshRenderers[i+1] != null)
|
||||||
|
{
|
||||||
|
Material[] materials = meshRenderers[i+1].sharedMaterials; // Get all Materials from child Mesh.
|
||||||
|
for(int j = 0; j < materials.Length; j++)
|
||||||
|
{
|
||||||
|
if(!uniqueMaterialsList.Contains(materials[j])) // If Material doesn't exists in the list then add it.
|
||||||
|
{
|
||||||
|
uniqueMaterialsList.Add(materials[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion Get MeshFilters, MeshRenderers and unique Materials from all children.
|
||||||
|
|
||||||
|
#region Combine children Meshes with the same Material to create submeshes for final Mesh:
|
||||||
|
List<CombineInstance> finalMeshCombineInstancesList = new List<CombineInstance>();
|
||||||
|
|
||||||
|
// If it will be over 65535 then use the 32 bit index buffer:
|
||||||
|
long verticesLength = 0;
|
||||||
|
|
||||||
|
for(int i = 0; i < uniqueMaterialsList.Count; i++) // Create each Mesh (submesh) from Meshes with the same Material.
|
||||||
|
{
|
||||||
|
List<CombineInstance> submeshCombineInstancesList = new List<CombineInstance>();
|
||||||
|
|
||||||
|
for(int j = 0; j < meshFilters.Length-1; j++) // Get only childeren Meshes (skip our Mesh).
|
||||||
|
{
|
||||||
|
if(meshRenderers[j+1] != null)
|
||||||
|
{
|
||||||
|
Material[] submeshMaterials = meshRenderers[j+1].sharedMaterials; // Get all Materials from child Mesh.
|
||||||
|
|
||||||
|
for(int k = 0; k < submeshMaterials.Length; k++)
|
||||||
|
{
|
||||||
|
// If Materials are equal, combine Mesh from this child:
|
||||||
|
if(uniqueMaterialsList[i] == submeshMaterials[k])
|
||||||
|
{
|
||||||
|
CombineInstance combineInstance = new CombineInstance();
|
||||||
|
combineInstance.subMeshIndex = k; // Mesh may consist of smaller parts - submeshes.
|
||||||
|
// Every part have different index. If there are 3 submeshes
|
||||||
|
// in Mesh then MeshRender needs 3 Materials to render them.
|
||||||
|
combineInstance.mesh = meshFilters[j+1].sharedMesh;
|
||||||
|
combineInstance.transform = meshFilters[j+1].transform.localToWorldMatrix;
|
||||||
|
submeshCombineInstancesList.Add(combineInstance);
|
||||||
|
verticesLength += combineInstance.mesh.vertices.Length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new Mesh (submesh) from Meshes with the same Material:
|
||||||
|
Mesh submesh = new Mesh();
|
||||||
|
|
||||||
|
#if UNITY_2017_3_OR_NEWER
|
||||||
|
if(verticesLength > Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
submesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; // Only works on Unity 2017.3 or higher.
|
||||||
|
}
|
||||||
|
|
||||||
|
submesh.CombineMeshes(submeshCombineInstancesList.ToArray(), true);
|
||||||
|
#else
|
||||||
|
// Below Unity 2017.3 if vertices count is above the limit then an error appears in the console when we use the below method.
|
||||||
|
// Anyway we don't stop the algorithm here beacuse we want to count the entire number of vertices in the children meshes:
|
||||||
|
if(verticesLength <= Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
submesh.CombineMeshes(submeshCombineInstancesList.ToArray(), true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
CombineInstance finalCombineInstance = new CombineInstance();
|
||||||
|
finalCombineInstance.subMeshIndex = 0;
|
||||||
|
finalCombineInstance.mesh = submesh;
|
||||||
|
finalCombineInstance.transform = Matrix4x4.identity;
|
||||||
|
finalMeshCombineInstancesList.Add(finalCombineInstance);
|
||||||
|
}
|
||||||
|
#endregion Combine submeshes (children Meshes) with the same Material.
|
||||||
|
|
||||||
|
#region Set Materials array & combine submeshes into one multimaterial Mesh:
|
||||||
|
meshRenderers[0].sharedMaterials = uniqueMaterialsList.ToArray();
|
||||||
|
|
||||||
|
Mesh combinedMesh = new Mesh();
|
||||||
|
combinedMesh.name = name;
|
||||||
|
|
||||||
|
#if UNITY_2017_3_OR_NEWER
|
||||||
|
if(verticesLength > Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
combinedMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; // Only works on Unity 2017.3 or higher.
|
||||||
|
}
|
||||||
|
|
||||||
|
combinedMesh.CombineMeshes(finalMeshCombineInstancesList.ToArray(), false);
|
||||||
|
GenerateUV(combinedMesh);
|
||||||
|
meshFilters[0].sharedMesh = combinedMesh;
|
||||||
|
DeactivateCombinedGameObjects(meshFilters);
|
||||||
|
|
||||||
|
if(showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
if(verticesLength <= Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
Debug.Log("<color=#00cc00><b>Mesh \""+name+"\" was created from "+(meshFilters.Length-1)+" children meshes and has "
|
||||||
|
+finalMeshCombineInstancesList.Count+" submeshes, and "+verticesLength+" vertices.</b></color>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("<color=#ff3300><b>Mesh \""+name+"\" was created from "+(meshFilters.Length-1)+" children meshes and has "
|
||||||
|
+finalMeshCombineInstancesList.Count+" submeshes, and "+verticesLength
|
||||||
|
+" vertices. Some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices.</b></color>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(verticesLength <= Mesh16BitBufferVertexLimit)
|
||||||
|
{
|
||||||
|
combinedMesh.CombineMeshes(finalMeshCombineInstancesList.ToArray(), false);
|
||||||
|
GenerateUV(combinedMesh);
|
||||||
|
meshFilters[0].sharedMesh = combinedMesh;
|
||||||
|
DeactivateCombinedGameObjects(meshFilters);
|
||||||
|
|
||||||
|
if(showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
Debug.Log("<color=#00cc00><b>Mesh \""+name+"\" was created from "+(meshFilters.Length-1)+" children meshes and has "
|
||||||
|
+finalMeshCombineInstancesList.Count+" submeshes, and "+verticesLength+" vertices.</b></color>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(showCreatedMeshInfo)
|
||||||
|
{
|
||||||
|
Debug.Log("<color=red><b>The mesh vertex limit is 65535! The created mesh had "+verticesLength+" vertices. Upgrade Unity version to"
|
||||||
|
+" 2017.3 or higher to avoid this limit (some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices).</b></color>");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endregion Set Materials array & combine submeshes into one multimaterial Mesh.
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeactivateCombinedGameObjects(MeshFilter[] meshFilters)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < meshFilters.Length-1; i++) // Skip first MeshFilter belongs to this GameObject in this loop.
|
||||||
|
{
|
||||||
|
if(!destroyCombinedChildren)
|
||||||
|
{
|
||||||
|
if(deactivateCombinedChildren)
|
||||||
|
{
|
||||||
|
meshFilters[i+1].gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
if(deactivateCombinedChildrenMeshRenderers)
|
||||||
|
{
|
||||||
|
MeshRenderer meshRenderer = meshFilters[i+1].gameObject.GetComponent<MeshRenderer>();
|
||||||
|
if(meshRenderer != null)
|
||||||
|
{
|
||||||
|
meshRenderer.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DestroyImmediate(meshFilters[i+1].gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateUV(Mesh combinedMesh)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
if(generateUVMap)
|
||||||
|
{
|
||||||
|
UnityEditor.UnwrapParam unwrapParam = new UnityEditor.UnwrapParam();
|
||||||
|
UnityEditor.UnwrapParam.SetDefaults(out unwrapParam);
|
||||||
|
UnityEditor.Unwrapping.GenerateSecondaryUVSet(combinedMesh, unwrapParam);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
18
Assets/MeshCombiner/Scripts/MeshCombiner.cs.meta
Normal file
18
Assets/MeshCombiner/Scripts/MeshCombiner.cs.meta
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 24fb3eb29eeebd04d87475bbfb984a31
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
AssetOrigin:
|
||||||
|
serializedVersion: 1
|
||||||
|
productId: 157192
|
||||||
|
packageName: Mesh Combiner
|
||||||
|
packageVersion: 1.2
|
||||||
|
assetPath: Assets/MeshCombiner/Scripts/MeshCombiner.cs
|
||||||
|
uploadId: 399985
|
||||||
BIN
Assets/MeshCombiner/readme.pdf
Normal file
BIN
Assets/MeshCombiner/readme.pdf
Normal file
Binary file not shown.
14
Assets/MeshCombiner/readme.pdf.meta
Normal file
14
Assets/MeshCombiner/readme.pdf.meta
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 02ac7360968340d469ead7285ab6ea15
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
AssetOrigin:
|
||||||
|
serializedVersion: 1
|
||||||
|
productId: 157192
|
||||||
|
packageName: Mesh Combiner
|
||||||
|
packageVersion: 1.2
|
||||||
|
assetPath: Assets/MeshCombiner/readme.pdf
|
||||||
|
uploadId: 399985
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: b1c41e022ae344de08711565989f6bfe
|
guid: b1c41e022ae344de08711565989f6bfe
|
||||||
ModelImporter:
|
ModelImporter:
|
||||||
serializedVersion: 22200
|
serializedVersion: 24200
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
materials:
|
materials:
|
||||||
@@ -16,8 +16,6 @@ ModelImporter:
|
|||||||
optimizeGameObjects: 0
|
optimizeGameObjects: 0
|
||||||
removeConstantScaleCurves: 0
|
removeConstantScaleCurves: 0
|
||||||
motionNodeName:
|
motionNodeName:
|
||||||
rigImportErrors:
|
|
||||||
rigImportWarnings:
|
|
||||||
animationImportErrors:
|
animationImportErrors:
|
||||||
animationImportWarnings:
|
animationImportWarnings:
|
||||||
animationRetargetingWarnings:
|
animationRetargetingWarnings:
|
||||||
@@ -35,7 +33,7 @@ ModelImporter:
|
|||||||
isReadable: 0
|
isReadable: 0
|
||||||
meshes:
|
meshes:
|
||||||
lODScreenPercentages: []
|
lODScreenPercentages: []
|
||||||
globalScale: 1
|
globalScale: 100
|
||||||
meshCompression: 0
|
meshCompression: 0
|
||||||
addColliders: 0
|
addColliders: 0
|
||||||
useSRGBMaterialColor: 1
|
useSRGBMaterialColor: 1
|
||||||
@@ -58,6 +56,9 @@ ModelImporter:
|
|||||||
maxBonesPerVertex: 4
|
maxBonesPerVertex: 4
|
||||||
minBoneWeight: 0.001
|
minBoneWeight: 0.001
|
||||||
optimizeBones: 1
|
optimizeBones: 1
|
||||||
|
generateMeshLods: 0
|
||||||
|
meshLodGenerationFlags: 0
|
||||||
|
maximumMeshLod: -1
|
||||||
meshOptimizationFlags: -1
|
meshOptimizationFlags: -1
|
||||||
indexFormat: 0
|
indexFormat: 0
|
||||||
secondaryUVAngleDistortion: 8
|
secondaryUVAngleDistortion: 8
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -27,7 +27,7 @@ Transform:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 0.1, y: 0.1, z: 0.1}
|
m_LocalScale: {x: 0.08, y: 0.08, z: 0.08}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
|
|||||||
@@ -683,7 +683,7 @@ ParticleSystemRenderer:
|
|||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 6888e6f8804259149a238ce4c6a74f59, type: 2}
|
- {fileID: 2100000, guid: 7e2e81cc0b156ce419830371ca3c39d5, type: 2}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
@@ -706,7 +706,7 @@ ParticleSystemRenderer:
|
|||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_RenderMode: 0
|
m_RenderMode: 4
|
||||||
m_MeshDistribution: 0
|
m_MeshDistribution: 0
|
||||||
m_SortMode: 0
|
m_SortMode: 0
|
||||||
m_MinParticleSize: 0
|
m_MinParticleSize: 0
|
||||||
@@ -729,7 +729,7 @@ ParticleSystemRenderer:
|
|||||||
m_VertexStreams: 00010304
|
m_VertexStreams: 00010304
|
||||||
m_UseCustomTrailVertexStreams: 0
|
m_UseCustomTrailVertexStreams: 0
|
||||||
m_TrailVertexStreams: 00010304
|
m_TrailVertexStreams: 00010304
|
||||||
m_Mesh: {fileID: 0}
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
m_Mesh1: {fileID: 0}
|
m_Mesh1: {fileID: 0}
|
||||||
m_Mesh2: {fileID: 0}
|
m_Mesh2: {fileID: 0}
|
||||||
m_Mesh3: {fileID: 0}
|
m_Mesh3: {fileID: 0}
|
||||||
@@ -991,8 +991,8 @@ ParticleSystem:
|
|||||||
startSize:
|
startSize:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
minMaxState: 3
|
minMaxState: 3
|
||||||
scalar: 0.05
|
scalar: 0.03
|
||||||
minScalar: 0.025
|
minScalar: 0.02
|
||||||
maxCurve:
|
maxCurve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Curve:
|
m_Curve:
|
||||||
@@ -1574,7 +1574,7 @@ ParticleSystem:
|
|||||||
rateOverTime:
|
rateOverTime:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
minMaxState: 0
|
minMaxState: 0
|
||||||
scalar: 4
|
scalar: 5
|
||||||
minScalar: 10
|
minScalar: 10
|
||||||
maxCurve:
|
maxCurve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -5519,7 +5519,7 @@ ParticleSystemRenderer:
|
|||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 6888e6f8804259149a238ce4c6a74f59, type: 2}
|
- {fileID: 2100000, guid: 7e2e81cc0b156ce419830371ca3c39d5, type: 2}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
@@ -5542,7 +5542,7 @@ ParticleSystemRenderer:
|
|||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_MaskInteraction: 0
|
m_MaskInteraction: 0
|
||||||
m_RenderMode: 0
|
m_RenderMode: 4
|
||||||
m_MeshDistribution: 0
|
m_MeshDistribution: 0
|
||||||
m_SortMode: 0
|
m_SortMode: 0
|
||||||
m_MinParticleSize: 0
|
m_MinParticleSize: 0
|
||||||
@@ -5565,7 +5565,7 @@ ParticleSystemRenderer:
|
|||||||
m_VertexStreams: 00010304
|
m_VertexStreams: 00010304
|
||||||
m_UseCustomTrailVertexStreams: 0
|
m_UseCustomTrailVertexStreams: 0
|
||||||
m_TrailVertexStreams: 00010304
|
m_TrailVertexStreams: 00010304
|
||||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
m_Mesh1: {fileID: 0}
|
m_Mesh1: {fileID: 0}
|
||||||
m_Mesh2: {fileID: 0}
|
m_Mesh2: {fileID: 0}
|
||||||
m_Mesh3: {fileID: 0}
|
m_Mesh3: {fileID: 0}
|
||||||
@@ -5763,7 +5763,7 @@ ParticleSystem:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
minMaxState: 0
|
minMaxState: 0
|
||||||
minColor: {r: 1, g: 1, b: 1, a: 1}
|
minColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
maxColor: {r: 0, g: 1, b: 0.9098039, a: 1}
|
maxColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
maxGradient:
|
maxGradient:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
key0: {r: 1, g: 1, b: 1, a: 1}
|
key0: {r: 1, g: 1, b: 1, a: 1}
|
||||||
@@ -5827,8 +5827,8 @@ ParticleSystem:
|
|||||||
startSize:
|
startSize:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
minMaxState: 3
|
minMaxState: 3
|
||||||
scalar: 0.12
|
scalar: 0.06
|
||||||
minScalar: 0.1
|
minScalar: 0.04
|
||||||
maxCurve:
|
maxCurve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Curve:
|
m_Curve:
|
||||||
@@ -5880,8 +5880,8 @@ ParticleSystem:
|
|||||||
startSizeY:
|
startSizeY:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
minMaxState: 3
|
minMaxState: 3
|
||||||
scalar: 1
|
scalar: 0.05
|
||||||
minScalar: 1
|
minScalar: 0.1
|
||||||
maxCurve:
|
maxCurve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Curve:
|
m_Curve:
|
||||||
@@ -5933,8 +5933,8 @@ ParticleSystem:
|
|||||||
startSizeZ:
|
startSizeZ:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
minMaxState: 3
|
minMaxState: 3
|
||||||
scalar: 1
|
scalar: 0.05
|
||||||
minScalar: 1
|
minScalar: 0.07
|
||||||
maxCurve:
|
maxCurve:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Curve:
|
m_Curve:
|
||||||
@@ -11269,14 +11269,18 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 614bffbd597c49349a47f76b0ba8b277, type: 3}
|
m_Script: {fileID: 11500000, guid: 614bffbd597c49349a47f76b0ba8b277, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier: Assembly-CSharp::Player
|
m_EditorClassIdentifier: Assembly-CSharp::Player
|
||||||
jumpForce: 3
|
jumpForce: 2.5
|
||||||
gravity: 7
|
|
||||||
rb: {fileID: 581798941}
|
rb: {fileID: 581798941}
|
||||||
splashObject: {fileID: 9000420296853654146, guid: 28c1e4391077e5c4e98f5924dc346fd9, type: 3}
|
splashObject: {fileID: 9000420296853654146, guid: 28c1e4391077e5c4e98f5924dc346fd9, type: 3}
|
||||||
splashParent: {fileID: 1850425825}
|
splashParent: {fileID: 1850425825}
|
||||||
deadParticle: {fileID: 239977915}
|
deadParticle: {fileID: 239977915}
|
||||||
jumpParticle: {fileID: 185655302}
|
jumpParticle: {fileID: 185655302}
|
||||||
cinemachineImpulseSource: {fileID: 581798944}
|
cinemachineImpulseSource: {fileID: 581798944}
|
||||||
|
playerMaterial: {fileID: 2100000, guid: 7e2e81cc0b156ce419830371ca3c39d5, type: 2}
|
||||||
|
playerMaterialColors:
|
||||||
|
- {r: 0, g: 1, b: 0.98041606, a: 0}
|
||||||
|
- {r: 0, g: 1, b: 0.59772396, a: 0}
|
||||||
|
- {r: 0.8490566, g: 0.36445355, b: 0.75023574, a: 0}
|
||||||
--- !u!96 &581798943
|
--- !u!96 &581798943
|
||||||
TrailRenderer:
|
TrailRenderer:
|
||||||
serializedVersion: 4
|
serializedVersion: 4
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ public class Platform : MonoBehaviour, IPlatform
|
|||||||
[SerializeField] private List<GameObject> _platformPiece = new List<GameObject>();
|
[SerializeField] private List<GameObject> _platformPiece = new List<GameObject>();
|
||||||
[SerializeField] private Material _safeMaterial;
|
[SerializeField] private Material _safeMaterial;
|
||||||
[SerializeField] private Material _deathMaterial;
|
[SerializeField] private Material _deathMaterial;
|
||||||
|
[SerializeField] private ParticleSystem _particleSystem;
|
||||||
|
|
||||||
|
[SerializeField]private Color[] safeMaterialColors;
|
||||||
|
[SerializeField] private Color[] deathMaterialColors;
|
||||||
|
|
||||||
public List<GameObject> platformPiece => _platformPiece;
|
public List<GameObject> platformPiece => _platformPiece;
|
||||||
public Material safeMaterial => _safeMaterial;
|
public Material safeMaterial => _safeMaterial;
|
||||||
@@ -21,6 +25,18 @@ public class Platform : MonoBehaviour, IPlatform
|
|||||||
[Inject] IPlatformManager platformManager;
|
[Inject] IPlatformManager platformManager;
|
||||||
[Inject] IScoreService IscoreService;
|
[Inject] IScoreService IscoreService;
|
||||||
[Inject] IAudioController IaudioController;
|
[Inject] IAudioController IaudioController;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
if(_particleSystem == null) _particleSystem = GetComponent<ParticleSystem>();
|
||||||
|
_safeMaterial.color = ReturnMaterialColor(safeMaterialColors);
|
||||||
|
_deathMaterial.color = ReturnMaterialColor(deathMaterialColors);
|
||||||
|
}
|
||||||
|
|
||||||
|
Color ReturnMaterialColor(Color[] color)
|
||||||
|
{
|
||||||
|
return color[Random.Range(0,color.Length)];
|
||||||
|
}
|
||||||
public void SetPlatformRule(IPlatformRule platformRule)
|
public void SetPlatformRule(IPlatformRule platformRule)
|
||||||
{
|
{
|
||||||
_platformRule = platformRule;
|
_platformRule = platformRule;
|
||||||
@@ -35,9 +51,18 @@ public class Platform : MonoBehaviour, IPlatform
|
|||||||
Debug.Log("Score Increased");
|
Debug.Log("Score Increased");
|
||||||
IscoreService.AddScore();
|
IscoreService.AddScore();
|
||||||
IaudioController.PlayScoredSound();
|
IaudioController.PlayScoredSound();
|
||||||
|
_particleSystem.Play();
|
||||||
|
HideThisPlatfromPiece();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void HideThisPlatfromPiece()
|
||||||
|
{
|
||||||
|
foreach(var piece in _platformPiece)
|
||||||
|
{
|
||||||
|
piece.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
@@ -72,6 +97,7 @@ public class FirstPlatform : IPlatformRule
|
|||||||
{
|
{
|
||||||
piece.SetActive(true);
|
piece.SetActive(true);
|
||||||
piece.GetComponent<Renderer>().material = platform.safeMaterial;
|
piece.GetComponent<Renderer>().material = platform.safeMaterial;
|
||||||
|
piece.gameObject.SetActive(true);
|
||||||
piece.tag = "Safe";
|
piece.tag = "Safe";
|
||||||
}
|
}
|
||||||
platform.platformPiece[Random.Range(1,platform.platformPiece.Count)].gameObject.SetActive(false);
|
platform.platformPiece[Random.Range(1,platform.platformPiece.Count)].gameObject.SetActive(false);
|
||||||
@@ -87,6 +113,7 @@ public class OtherPlatform : IPlatformRule
|
|||||||
{
|
{
|
||||||
piece.SetActive(true);
|
piece.SetActive(true);
|
||||||
piece.GetComponent<Renderer>().material = platform.safeMaterial;
|
piece.GetComponent<Renderer>().material = platform.safeMaterial;
|
||||||
|
piece.gameObject.SetActive(true);
|
||||||
piece.tag = "Safe";
|
piece.tag = "Safe";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ public class Player : MonoBehaviour, IPlayer
|
|||||||
[SerializeField] private ParticleSystem jumpParticle;
|
[SerializeField] private ParticleSystem jumpParticle;
|
||||||
[SerializeField] private CinemachineImpulseSource cinemachineImpulseSource;
|
[SerializeField] private CinemachineImpulseSource cinemachineImpulseSource;
|
||||||
|
|
||||||
|
[SerializeField] private Material playerMaterial;
|
||||||
|
[SerializeField] Color[] playerMaterialColors;
|
||||||
|
|
||||||
public bool isDead { get; private set; }
|
public bool isDead { get; private set; }
|
||||||
|
|
||||||
[Inject] private IDeathScreenController IdeathScreenController;
|
[Inject] private IDeathScreenController IdeathScreenController;
|
||||||
@@ -22,6 +25,7 @@ public class Player : MonoBehaviour, IPlayer
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
isDead = false;
|
isDead = false;
|
||||||
|
playerMaterial.color = playerMaterialColors[Random.Range(0, playerMaterialColors.Length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCollisionEnter(Collision collision)
|
private void OnCollisionEnter(Collision collision)
|
||||||
@@ -46,8 +50,8 @@ public class Player : MonoBehaviour, IPlayer
|
|||||||
float splashYPos = collision.transform.position.y + 0.155f;
|
float splashYPos = collision.transform.position.y + 0.155f;
|
||||||
ContactPoint contact = collision.contacts[0];
|
ContactPoint contact = collision.contacts[0];
|
||||||
Vector3 surfacePoint = new Vector3(contact.point.x, splashYPos, contact.point.z);
|
Vector3 surfacePoint = new Vector3(contact.point.x, splashYPos, contact.point.z);
|
||||||
GameObject instancedSplash = Instantiate(splashObject, surfacePoint, splashObject.transform.rotation, splashParent);
|
GameObject instancedSplash = Instantiate(splashObject, surfacePoint, splashObject.transform.rotation, collision.gameObject.transform);
|
||||||
instancedSplash.transform.localScale = new Vector3(Random.Range(0.08f, 0.1f), Random.Range(0.08f, 0.1f),1);
|
instancedSplash.transform.localScale = new Vector3(Random.Range(0.05f, 0.09f), Random.Range(0.05f, 0.09f),1);
|
||||||
Destroy(instancedSplash, 2f);
|
Destroy(instancedSplash, 2f);
|
||||||
}
|
}
|
||||||
private void Die()
|
private void Die()
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
PhysicsManager:
|
PhysicsManager:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 20
|
serializedVersion: 20
|
||||||
m_Gravity: {x: 0, y: -9.81, z: 0}
|
m_Gravity: {x: 0, y: -7, z: 0}
|
||||||
m_DefaultMaterial: {fileID: 0}
|
m_DefaultMaterial: {fileID: 0}
|
||||||
m_BounceThreshold: 2
|
m_BounceThreshold: 2
|
||||||
m_DefaultMaxDepenetrationVelocity: 10
|
m_DefaultMaxDepenetrationVelocity: 10
|
||||||
|
|||||||
Reference in New Issue
Block a user