add games

This commit is contained in:
2022-11-10 21:56:29 -03:00
commit 35300554e2
2182 changed files with 325017 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 556f0ce8fab07c64d8b6e775d4e949e6
folderAsset: yes
timeCreated: 1505827091
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
/**
* Provides some additional functionality when the FbxSdk and FbxExporter packages
* are available in the project.
*/
using UnityEngine;
using UnityEditor;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using ProBuilder2.MeshOperations;
using System.Collections.Generic;
using System;
using System.Linq;
using System.Reflection;
#if PROBUILDER_FBX_ENABLED
using Unity.FbxSdk;
using FbxExporters;
using FbxExporters.Editor;
#endif
namespace ProBuilder2.Common
{
/*
* Options when exporting FBX files.
*/
public class pb_FbxOptions
{
public bool quads;
}
[InitializeOnLoad]
public static class pb_Fbx
{
private static bool m_FbxIsLoaded = false;
public static bool FbxEnabled { get { return m_FbxIsLoaded; } }
#if PROBUILDER_FBX_ENABLED
private static pb_FbxOptions m_FbxOptions = new pb_FbxOptions() {
quads = true
};
static pb_Fbx()
{
TryLoadFbxSupport();
if(m_FbxIsLoaded)
PrefabUtility.prefabInstanceUpdated += PrefabInstanceUpdated;
}
static void TryLoadFbxSupport()
{
if(m_FbxIsLoaded)
return;
FbxPrefab.OnUpdate += OnFbxUpdate;
ModelExporter.RegisterMeshCallback<pb_Object>(GetMeshForComponent, true);
m_FbxOptions.quads = pb_PreferencesInternal.GetBool("Export::m_FbxQuads", true);
m_FbxIsLoaded = true;
}
private static void OnFbxUpdate(FbxPrefab updatedInstance, IEnumerable<GameObject> updatedObjects)
{
// System.Text.StringBuilder sb = new System.Text.StringBuilder();
// sb.AppendLine("OnFbxUpdate:");
// sb.AppendLine("instance: " + updatedInstance.name + " is asset: " + !string.IsNullOrEmpty(AssetDatabase.GetAssetPath(updatedInstance)));
// sb.AppendLine("objects:");
// foreach(GameObject go in updatedObjects)
// sb.AppendLine("\t" + go.name);
// pb_Log.Debug(sb.ToString());
}
private static bool GetMeshForComponent(ModelExporter exporter, pb_Object component, FbxNode fbxNode)
{
Mesh mesh = new Mesh();
Material[] materials = null;
pb_MeshCompiler.Compile(component, ref mesh, out materials, m_FbxOptions.quads ? MeshTopology.Quads : MeshTopology.Triangles);
exporter.ExportMesh(mesh, fbxNode, materials);
UnityEngine.Object.DestroyImmediate(mesh);
// since probuilder can't handle mesh assets that may be externally reloaded, just strip pb
// stuff for now.
pb_Entity entity = component.GetComponent<pb_Entity>();
component.dontDestroyMeshOnDelete = true;
UnityEngine.Object.DestroyImmediate(component);
if(entity != null)
UnityEngine.Object.DestroyImmediate(entity);
return true;
}
private static void PrefabInstanceUpdated(GameObject go)
{
// pb_Log.Debug("instance updated: " + go.name);
}
#endif
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 3fce8ab926626f84a988bc7e668a97ba
timeCreated: 1505754415
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 47f6046931f8f4bcaa07e69a86e4b9d4

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 183b3c0f260e2b14b9acdedcf3da349d

View File

@@ -0,0 +1,14 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Deprecated - see MenuActions/Export/ExportObj.cs
*/
public class pb_ExportObj : Editor
{}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fa9d263a6f6fb4e809bbd52002af2cca
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,70 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
public class pb_GenerateUV2 : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Actions/Generate UV2 - Selection", true, pb_Constant.MENU_ACTIONS + 20)]
public static bool VerifyGenerateUV2Selection()
{
return pbUtil.GetComponents<pb_Object>(Selection.transforms).Length > 0;
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Actions/Generate UV2 - Selection", false, pb_Constant.MENU_ACTIONS + 20)]
public static void MenuGenerateUV2Selection()
{
pb_Object[] sel = Selection.transforms.GetComponents<pb_Object>();
if( !Menu_GenerateUV2(sel) )
return; // user canceled
if(sel.Length > 0)
pb_EditorUtility.ShowNotification("Generated UV2 for " + sel.Length + " Meshes");
else
pb_EditorUtility.ShowNotification("Nothing Selected");
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Actions/Generate UV2 - Scene", false, pb_Constant.MENU_ACTIONS + 20)]
public static void MenuGenerateUV2Scene()
{
pb_Object[] sel = (pb_Object[])FindObjectsOfType(typeof(pb_Object));
if( !Menu_GenerateUV2(sel) )
return;
if(sel.Length > 0)
pb_EditorUtility.ShowNotification("Generated UV2 for " + sel.Length + " Meshes");
else
pb_EditorUtility.ShowNotification("No ProBuilder Objects Found");
}
static bool Menu_GenerateUV2(pb_Object[] selected)
{
for(int i = 0; i < selected.Length; i++)
{
if(selected.Length > 3)
{
if( EditorUtility.DisplayCancelableProgressBar(
"Generating UV2 Channel",
"pb_Object: " + selected[i].name + ".",
(((float)i+1) / selected.Length)))
{
EditorUtility.ClearProgressBar();
Debug.LogWarning("User canceled UV2 generation. " + (selected.Length-i) + " pb_Objects left without lightmap UVs.");
return false;
}
}
// True parameter forcibly generates UV2. Otherwise if pbDisableAutoUV2Generation is true then UV2 wouldn't be built.
selected[i].Optimize(true);
}
EditorUtility.ClearProgressBar();
return true;
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f1099344d2fd4346ac294e9360c6335
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,14 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* See MenuActions/Export/ExportAsset.cs
*/
[System.Obsolete]
public class pb_MakeMeshAsset : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a6e30a090463d5f4083d9e62cdedc291
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,26 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using ProBuilder2.MeshOperations;
using System.Linq;
namespace ProBuilder2.Actions
{
/**
* Menu interface for pb_ProBuilderize functions.
*
* Deprecated as of 2.6.1.
* This file remains only for backwards compatibility; you may
* safely delete it.
*
* See also: ProBuilder2.Actions.ProBuilderize.
*/
public class pb_ProBuilderize : Editor
{
}
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 11e1d123bde81b142a53aa85e15df6b4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,119 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
public class pb_StripProBuilderScripts : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Actions/Strip All ProBuilder Scripts in Scene")]
public static void StripAllScenes()
{
if(!EditorUtility.DisplayDialog("Strip ProBuilder Scripts", "This will remove all ProBuilder scripts in the scene. You will no longer be able to edit these objects. There is no undo, please exercise caution!\n\nAre you sure you want to do this?", "Okay", "Cancel"))
return;
pb_Object[] all = (pb_Object[]) Resources.FindObjectsOfTypeAll(typeof(pb_Object) );
Strip(all);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Actions/Strip ProBuilder Scripts in Selection", true, 0)]
public static bool VerifyStripSelection()
{
return pbUtil.GetComponents<pb_Object>(Selection.transforms).Length > 0;
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Actions/Strip ProBuilder Scripts in Selection")]
public static void StripAllSelected()
{
if(!EditorUtility.DisplayDialog("Strip ProBuilder Scripts", "This will remove all ProBuilder scripts on the selected objects. You will no longer be able to edit these objects. There is no undo, please exercise caution!\n\nAre you sure you want to do this?", "Okay", "Cancel"))
return;
foreach(Transform t in Selection.transforms)
{
foreach(pb_Object pb in t.GetComponentsInChildren<pb_Object>(true))
DoStrip(pb);
}
}
public static void Strip(pb_Object[] all)
{
for(int i = 0; i < all.Length; i++)
{
if( EditorUtility.DisplayCancelableProgressBar(
"Stripping ProBuilder Scripts",
"Working over " + all[i].id + ".",
((float)i / all.Length)) )
break;
DoStrip(all[i]);
}
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("Strip ProBuilder Scripts", "Successfully stripped out all ProBuilder components.", "Okay");
if(pb_Editor.instance)
pb_Editor.instance.UpdateSelection();
}
public static void DoStrip(pb_Object pb)
{
try
{
GameObject go = pb.gameObject;
Renderer ren = go.GetComponent<Renderer>();
if(ren != null)
pb_EditorUtility.SetSelectionRenderState(ren, pb_EditorUtility.GetSelectionRenderState());
if( PrefabUtility.GetPrefabType(go) == PrefabType.Prefab )
return;
pb_EditorUtility.VerifyMesh(pb);
if(pb.msh == null)
{
DestroyImmediate(pb);
if(go.GetComponent<pb_Entity>())
DestroyImmediate(go.GetComponent<pb_Entity>());
return;
}
string cachedMeshPath;
Mesh cachedMesh;
// if meshes are assets and the mesh cache is valid don't duplicate the mesh to an instance.
if( pb_PreferencesInternal.GetBool(pb_Constant.pbMeshesAreAssets) && pb_EditorMeshUtility.GetCachedMesh(pb, out cachedMeshPath, out cachedMesh) )
{
pb.dontDestroyMeshOnDelete = true;
DestroyImmediate(pb);
if(go.GetComponent<pb_Entity>())
DestroyImmediate(go.GetComponent<pb_Entity>());
}
else
{
Mesh m = pb_MeshUtility.DeepCopy(pb.msh);
DestroyImmediate(pb);
if(go.GetComponent<pb_Entity>())
DestroyImmediate(go.GetComponent<pb_Entity>());
go.GetComponent<MeshFilter>().sharedMesh = m;
if(go.GetComponent<MeshCollider>())
go.GetComponent<MeshCollider>().sharedMesh = m;
}
}
catch {}
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5e4bb3a0bf3880243833bb679201e676
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 95ffe97929f188343b04cec5d95e9db9

View File

@@ -0,0 +1,21 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for Bridge edges functions.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_BridgeEdges : Editor {}
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3d47ec8636eedb54bbd43b455ba5a552
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using ProBuilder2.MeshOperations;
namespace ProBuilder2.Actions
{
/**
* Menu interface for 'Conform Normals' action.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_ConformNormals : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bb28d804d51dbfa47bc622ef7a5185bd
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,20 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using System.Linq;
namespace ProBuilder2.Actions
{
/**
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_ConnectEdges : Editor {}
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b8c23873415ae5a42b9fd20c21b4be67
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for deleting and detaching faces.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_DetachDeleteFace : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 513fdd2b40fc74479babf983da872481
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using ProBuilder2.MeshOperations;
namespace ProBuilder2.Actions
{
/**
* Menu interface for extruding elements.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_ExtrudeElement : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c00f613790b6fff49b970d38a9db8e38
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for flip edges actions.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_FlipEdge : Editor {}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4c1c713b5d3d64b5abbfa9dd85a4d3a3
timeCreated: 1446755455
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for flip normals actions.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_FlipNormals : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e9004076e3f925b4c88587fae435c19a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Set the pivot point of a pb_Object mesh to 0,0,0 while retaining current world space.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_FreezeTransform : Editor {}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9636271c872be7643b621a5f9766de4d
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,26 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using ProBuilder2.MeshOperations;
namespace ProBuilder2.Actions
{
/**
* Merge 2 or more faces into a single face. Merged face
* retains the properties of the first selected face in the
* event of conflicts.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_MergeFaces : Editor {}
}
#endif

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 82309ed2f1b8d5d46a4b10b95dfa2338
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,20 @@
/**
* @ Matt1988
* This extension was built by @Matt1988
*/
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_SetPivot : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 65a620b923aa1cb48a88b3c30dab222a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using ProBuilder2.MeshOperations;
namespace ProBuilder2.Actions
{
/**
* Triangulates a ProBuilder object.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_Triangulate : Editor {}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 013665b62f86cd34da56ceeceb5b5411
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,22 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for vertex merge / weld functions.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_VertexMergeWeld : Editor {}
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: be7875c6d324f894297948afb22243c5
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0bbef3fd9ac419a418d9d6ac669e36c9

View File

@@ -0,0 +1,28 @@
#if !UNITY_4_6 && !UNITY_4_7
#define UNITY_5
#endif
using UnityEngine;
using System.Collections;
using UnityEditor;
using ProBuilder2.Common;
namespace ProBuilder2.Actions
{
public class pb_CleanLeakedMeshes : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Clean Leaked Meshes", false, pb_Constant.MENU_REPAIR)]
public static void CleanUp()
{
// if(EditorUtility.DisplayDialog("Clean Leaked Meshes?",
// "Cleaning leaked meshes will permenantly delete any deleted pb_Objects, are you sure you don't want to undo?", "Clean Up", "Stay Dirty"))
// {
#if !UNITY_5
EditorUtility.UnloadUnusedAssetsIgnoreManagedReferences();
#else
EditorUtility.UnloadUnusedAssetsImmediate();
#endif
// }
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 75ef8594f27154942a55ce5d30f0fb1e
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,50 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.EditorCommon;
using ProBuilder2.Common;
namespace ProBuilder2.Actions
{
/**
* Menu interface for manually re-generating all ProBuilder geometry in scene.
*/
public class pb_ForceSceneRefresh : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Force Refresh Scene", false, pb_Constant.MENU_REPAIR)]
public static void MenuForceSceneRefresh()
{
ForceRefresh(true);
}
/**
* \brief Force refreshes all meshes in scene.
*/
private static void ForceRefresh(bool interactive)
{
pb_Object[] all = (pb_Object[])GameObject.FindObjectsOfType(typeof(pb_Object));
for(int i = 0; i < all.Length; i++)
{
if(interactive)
EditorUtility.DisplayProgressBar(
"Refreshing ProBuilder Objects",
"Reshaping pb_Object " + all[i].id + ".",
((float)i / all.Length));
try
{
all[i].ToMesh();
all[i].Refresh();
all[i].Optimize();
}
catch {}
}
if(interactive)
{
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("Refresh ProBuilder Objects", "Successfully refreshed all ProBuilder objects in scene.", "Okay");
}
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b154e25dde0355e43a8eaa4d844baca6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,92 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.MeshOperations;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for manually regenerating all ProBuilder mesh references in scene.
*/
public class pb_RebuildMeshes : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Rebuild ProBuilder Objects", true, pb_Constant.MENU_REPAIR)]
private static bool VertifyRebuildMeshes()
{
return pbUtil.GetComponents<pb_Object>(Selection.transforms).Length > 0;
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Rebuild ProBuilder Objects", false, pb_Constant.MENU_REPAIR)]
public static void DoRebuildMeshes()
{
StripAndProBuilderize( pbUtil.GetComponents<pb_Object>(Selection.transforms) );
}
/**
* \brief Rebuild targets if they can't be refreshed.
*/
private static void StripAndProBuilderize(pb_Object[] targets, bool interactive = true)
{
for(int i = 0; i < targets.Length; i++)
{
if(interactive)
{
EditorUtility.DisplayProgressBar(
"Refreshing ProBuilder Objects",
"Reshaping pb_Object " + targets[i].id + ".",
((float)i / targets.Length));
}
pb_Object pb = targets[i];
try
{
pb.ToMesh();
pb.Refresh();
pb.Optimize();
}
catch
{
if(pb.msh != null)
RebuildProBuilderMesh(pb);
}
}
if(interactive)
{
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("Rebuild ProBuilder Objects", "Successfully rebuilt " + targets.Length + " ProBuilder Objects", "Okay");
}
}
private static void RebuildProBuilderMesh(pb_Object pb)
{
try
{
GameObject go = pb.gameObject;
pb.dontDestroyMeshOnDelete = true;
Undo.DestroyObjectImmediate(pb);
// don't delete pb_Entity here because it won't
// actually get removed till the next frame, and
// probuilderize wants to add it if it's missing
// (which it looks like it is from c# side but
// is not)
pb = Undo.AddComponent<pb_Object>(go);
pbMeshOps.ResetPbObjectWithMeshFilter(pb, true);
pb.ToMesh();
pb.Refresh();
pb.Optimize();
}
catch(System.Exception e)
{
Debug.LogError("Failed rebuilding ProBuilder mesh: " + e.ToString());
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d512ac746ccb7d54697ea83dad6af888
timeCreated: 1487601952
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.MeshOperations;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for manually regenerating all ProBuilder shared indices caches in selection.
*/
public class pb_RebuildSharedIndices : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Rebuild Shared Indices Cache", true, pb_Constant.MENU_REPAIR)]
private static bool VertifyRebuildMeshes()
{
return pbUtil.GetComponents<pb_Object>(Selection.transforms).Length > 0;
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Rebuild Shared Indices Cache", false, pb_Constant.MENU_REPAIR)]
public static void DoRebuildMeshes()
{
RebuildSharedIndices( pbUtil.GetComponents<pb_Object>(Selection.transforms) );
}
/**
* \brief Rebuild targets if they can't be refreshed.
*/
private static void RebuildSharedIndices(pb_Object[] targets, bool interactive = true)
{
for(int i = 0; i < targets.Length; i++)
{
if(interactive)
{
EditorUtility.DisplayProgressBar(
"Refreshing ProBuilder Objects",
"Reshaping pb_Object " + targets[i].id + ".",
((float)i / targets.Length));
}
pb_Object pb = targets[i];
try
{
pb.SetSharedIndices(pb_IntArrayUtility.ExtractSharedIndices(pb.vertices));
pb.ToMesh();
pb.Refresh();
pb.Optimize();
}
catch(System.Exception e)
{
Debug.LogError("Failed rebuilding " + pb.name + " shared indices cache.\n" + e.ToString());
}
}
if(interactive)
{
EditorUtility.ClearProgressBar();
EditorUtility.DisplayDialog("Rebuild Shared Index Cache", "Successfully rebuilt " + targets.Length + " shared index caches", "Okay");
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ef9241e5284141547955d3f7f7fe3c64
timeCreated: 1487604518
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using UnityEditor;
using UnityEngine;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for removing degerate triangles.
*/
public class pb_RemoveDegenerateTris : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Remove Degenerate Triangles", false, pb_Constant.MENU_REPAIR)]
public static void MenuRemoveDegenerateTriangles()
{
int count = 0;
foreach(pb_Object pb in pbUtil.GetComponents<pb_Object>(Selection.transforms))
{
pb.ToMesh();
int[] rm;
pb.RemoveDegenerateTriangles(out rm);
count += rm.Length;
pb.ToMesh();
pb.Refresh();
pb.Optimize();
}
pb_EditorUtility.ShowNotification("Removed " + (count/3) + " degenerate triangles.");
}
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a81d2e96055698b44978529b4db3ce83
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,35 @@
using UnityEditor;
using UnityEngine;
using System.Collections;
using ProBuilder2.MeshOperations;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for replacing vertex colors on broken objces.
*/
public class pb_RepairColors : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Rebuild Vertex Colors", false, pb_Constant.MENU_REPAIR)]
public static void MenuRepairColors()
{
int count = 0;
foreach(pb_Object pb in pbUtil.GetComponents<pb_Object>(Selection.transforms))
{
if( pb.colors == null || pb.colors.Length != pb.vertexCount )
{
pb.ToMesh();
pb.SetColors(pbUtil.FilledArray<Color>(Color.white, pb.vertexCount));
pb.Refresh();
pb.Optimize();
count++;
}
}
pb_EditorUtility.ShowNotification("Rebuilt colors for " + count + " ProBuilder Objects.");
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1485aec81bad32546971ab90a4790c0a
timeCreated: 1430525119
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
namespace ProBuilder2.Actions
{
/**
* File stub retained for backwards compatibility.
* You may safely delete this file.
*/
[System.Obsolete]
static class pb_RepairMeshReferences {}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c5d698f0521a16d4aa395123cc981041
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,9 @@
namespace ProBuilder2.Actions
{
/**
* File stub retained for backwards compatibility.
* You may safely delete this file.
*/
[System.Obsolete]
static class pb_RepairUV {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 47dbe8bc6aaf4444096d7e2fd54224b8
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,54 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.EditorCommon;
using ProBuilder2.Common;
using System.Linq;
namespace ProBuilder2.Actions
{
/**
* Menu interface for resetting the materials associated with special entity types.
*/
public class pb_ResetEntityMaterials : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Repair Entity Materials", false, pb_Constant.MENU_REPAIR)]
public static void MenuRefreshMeshReferences()
{
RepairEntityMaterials();
}
/**
* \brief Force refreshes all meshes in scene.
*/
private static void RepairEntityMaterials()
{
IEnumerable all = GameObject.FindObjectsOfType(typeof(pb_Entity))
.Where(x => ((pb_Entity)x).entityType == EntityType.Collider || ((pb_Entity)x).entityType == EntityType.Trigger);
Material ColliderMat = pb_Constant.ColliderMaterial;
Material TriggerMat = pb_Constant.TriggerMaterial;
if( ColliderMat == null )
{
Debug.LogError("ProBuilder cannot find Collider material! Make sure the Collider material asset is in \"Assets/ProCore/ProBuilder/Resources/Material\" folder.");
return;
}
if( TriggerMat == null )
{
Debug.LogError("ProBuilder cannot find Trigger material! Make sure the Trigger material asset is in \"Assets/ProCore/ProBuilder/Resources/Material\" folder.");
return;
}
foreach(pb_Entity ent in all)
{
MeshRenderer mr = ent.transform.GetComponent<MeshRenderer>() ?? ent.gameObject.AddComponent<MeshRenderer>();
mr.sharedMaterials = new Material[1] { ent.entityType == EntityType.Collider ? ColliderMat : TriggerMat };
}
EditorUtility.DisplayDialog("Repair Entity Materials", "Successfully reset special entity materials in scene.", "Okay");
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8381dcce248500d4dbe16edf867ea9d6
timeCreated: 1432643405
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.EditorCommon;
using System.Linq;
using ProBuilder2.Common;
namespace ProBuilder2.Actions
{
/**
* Menu interface for applying materials to pb_Object after upgrading from Basic to Advanced.
*/
public class pb_UpgradeBasicToAdvanced : Editor
{
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Upgrade Scene to Advanced", false, pb_Constant.MENU_REPAIR + 10)]
public static void MenuUpgradeSceneAdvanced()
{
if( !EditorUtility.DisplayDialog("Upgrade Scene to Advanced", "This utility sets the materials on every ProBuilder object in the scene. Continue?", "Okay", "Cancel") )
return;
DoUpgrade((pb_Object[]) Resources.FindObjectsOfTypeAll(typeof(pb_Object)));
EditorUtility.DisplayDialog("Upgrade ProBuilder Objects", "Successfully upgraded all ProBuilder objects in scene.\n\nIf any of the objects in the scene were prefabs you'll need to 'Apply' changes.", "Okay");
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Upgrade Selection to Advanced", false, pb_Constant.MENU_REPAIR + 10)]
public static void MenuUpgradeSelectionAdvanced()
{
if( !EditorUtility.DisplayDialog("Upgrade Selection to Advanced", "This utility sets the materials on every selected ProBuilder object. Continue?", "Okay", "Cancel") )
return;
DoUpgrade( Selection.gameObjects.SelectMany(x => x.GetComponentsInChildren<pb_Object>()).ToArray() );
EditorUtility.DisplayDialog("Upgrade ProBuilder Objects", "Successfully upgraded all ProBuilder objects in selection", "Okay");
}
private static void DoUpgrade(pb_Object[] all)
{
bool interactive = all != null && all.Length > 8;
for(int i = 0 ; i < all.Length; i++)
{
pb_Object pb = all[i];
if(interactive)
{
EditorUtility.DisplayProgressBar(
"Applying Materials",
"Setting pb_Object " + all[i].id + ".",
((float)i / all.Length));
}
pb.SetFaceMaterial(pb.faces, pb.gameObject.GetComponent<MeshRenderer>().sharedMaterial);
pb.ToMesh();
pb.Refresh();
pb.Optimize();
}
if(interactive)
{
EditorUtility.ClearProgressBar();
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2bc5914fb09a6db40abae1d25f7c85ee
timeCreated: 1485808349
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 56b05877db1c0b244b90f66abe6a5b9b

View File

@@ -0,0 +1,17 @@
using UnityEditor;
using UnityEngine;
using ProBuilder2.MeshOperations;
using System.Collections.Generic;
using System.Linq;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_EdgeSelection : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c61d11485194048a3bd2b542a79c6ca6
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,17 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for 'Grow Selection' and 'Shrink Selection'
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_ExpandSelection : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b65bcdf2cdd5c4642a467fa1923e4e33
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,21 @@
// Thanks to forum member @Igmon for this feature suggestion:
// http://www.sixbysevenstudio.com/forum/viewtopic.php?f=14&t=2374&p=4351#p4351
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Menu interface for inverting the current element selection.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_InvertSelection : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 254380e632ef56c4bbadfe9c7bf38a54
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,19 @@
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using System.Linq;
namespace ProBuilder2.Actions
{
/**
* Menu actions for selecting faces with a material or vertex color.
*
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_MaterialSelection : Editor {}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 8fa537ad62e88074ca9dd3bf2c1c4733
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 61334a31eca0fa14aa6c8c2f89cfc981

View File

@@ -0,0 +1,3 @@
/**
* Moved to EditorCore. This file remains for backwards compatibility reasons. You may safely delete it.
*/

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0c92e8890b3c18e4fa925168cb2ea002
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:

View File

@@ -0,0 +1,20 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Moved to pb_MenuAction implementation.
*/
[System.Obsolete("Moved to pb_MenuAction implementation. See SelectMaterial & SelectVertexColor")]
public class pb_MaterialSelectionShortcut : EditorWindow {}
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e2fd96fc912386d428fb624a682acd70
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1bf1d34ad531e104ab09517dbe835d2a

View File

@@ -0,0 +1,17 @@
#if !PROTOTYPE
using UnityEngine;
using UnityEditor;
using System.Collections;
using ProBuilder2.EditorCommon;
namespace ProBuilder2.Actions
{
/**
* Deprecated as of 2.6.0.
* This file remains only for backwards compatibility; you may
* safely delete it.
*/
public class pb_ProBuilderMenuItems : Editor {}
}
#endif

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bd9936dd0dc8c26479f3f4170f4735a7
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,25 @@
fileFormatVersion: 2
guid: 4df21bd079886d84699ca7be1316c7a7
timeCreated: 1494265284
licenseType: Store
PluginImporter:
serializedVersion: 1
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
Any:
enabled: 0
settings: {}
Editor:
enabled: 1
settings:
DefaultValueInitialized: true
WindowsStoreApps:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,170 @@
using UnityEngine;
using UnityEditor;
using System.Linq;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
public class pb_MenuItems : EditorWindow
{
// const string DOCUMENTATION_URL = "http://www.protoolsforunity3d.com/docs/probuilder/";
const string DOCUMENTATION_URL = "http://procore3d.github.io/probuilder2/";
private static pb_Editor editor { get { return pb_Editor.instance; } }
#region WINDOW
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/About", false, pb_Constant.MENU_ABOUT)]
public static void MenuInitAbout()
{
pb_AboutWindow.Init(true);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Documentation", false, pb_Constant.MENU_ABOUT)]
public static void MenuInitDocumentation()
{
Application.OpenURL(DOCUMENTATION_URL);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/" + pb_Constant.PRODUCT_NAME + " Window", false, pb_Constant.MENU_EDITOR)]
public static void OpenEditorWindow()
{
pb_Editor.MenuOpenWindow();
}
#endregion
#region CONTEXT SENSITIVE SHORTCUTS
static pb_Object[] selection { get { return Selection.transforms.GetComponents<pb_Object>(); } }
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Geometry/Extrude %e", true)]
private static bool MenuVerifyExtrude()
{
pb_Editor e = pb_Editor.instance;
return e != null &&
e.editLevel == EditLevel.Geometry &&
selection != null &&
selection.Length > 0 &&
(selection.Any(x => x.SelectedEdgeCount > 0) || selection.Any(x => x.SelectedFaces.Length > 0));
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Geometry/Extrude %e", false, pb_Constant.MENU_GEOMETRY + 3)]
private static void MenuDoExtrude()
{
pb_Menu_Commands.MenuExtrude(selection, false);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Selection/Select Loop &l", true, pb_Constant.MENU_SELECTION)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Selection/Select Ring &r", true, pb_Constant.MENU_SELECTION)]
private static bool MenuVerifyRingLoop()
{
if (editor == null || editor.editLevel != EditLevel.Geometry)
return false;
if (editor.selectionMode == SelectMode.Edge)
return pb_Selection.Top().Any(x => x.SelectedEdgeCount > 0);
else if (editor.selectionMode == SelectMode.Face)
return pb_Selection.Top().Any(x => x.SelectedFaceCount > 0);
return false;
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Selection/Select Loop &l", false, pb_Constant.MENU_SELECTION)]
private static void MenuSelectLoop()
{
switch (editor.selectionMode)
{
case SelectMode.Edge:
pb_Menu_Commands.MenuLoopSelection(selection);
break;
case SelectMode.Face:
pb_Menu_Commands.MenuLoopFaces(selection);
break;
}
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Selection/Select Ring &r", false, pb_Constant.MENU_SELECTION)]
private static void MenuSelectRing()
{
switch (editor.selectionMode)
{
case SelectMode.Edge:
pb_Menu_Commands.MenuRingSelection(selection);
break;
case SelectMode.Face:
pb_Menu_Commands.MenuRingFaces(selection);
break;
}
}
#endregion
#region VERTEX COLORS
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 1 &#1", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 2 &#2", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 3 &#3", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 4 &#4", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 5 &#5", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 6 &#6", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 7 &#7", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 8 &#8", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 9 &#9", true, pb_Constant.MENU_VERTEX_COLORS)]
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 0 &#0", true, pb_Constant.MENU_VERTEX_COLORS)]
public static bool VerifyApplyVertexColor()
{
return pb_Editor.instance != null && pb_Editor.instance.selectedVertexCount > 0;
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 1 &#1", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset1() {
pb_Vertex_Color_Toolbar.SetFaceColors(1);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 2 &#2", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset2() {
pb_Vertex_Color_Toolbar.SetFaceColors(2);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 3 &#3", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset3() {
pb_Vertex_Color_Toolbar.SetFaceColors(3);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 4 &#4", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset4() {
pb_Vertex_Color_Toolbar.SetFaceColors(4);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 5 &#5", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset5() {
pb_Vertex_Color_Toolbar.SetFaceColors(5);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 6 &#6", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset6() {
pb_Vertex_Color_Toolbar.SetFaceColors(6);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 7 &#7", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset7() {
pb_Vertex_Color_Toolbar.SetFaceColors(7);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 8 &#8", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset8() {
pb_Vertex_Color_Toolbar.SetFaceColors(8);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 9 &#9", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset9() {
pb_Vertex_Color_Toolbar.SetFaceColors(9);
}
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Vertex Colors/Set Selected Faces to Preset 0 &#0", false, pb_Constant.MENU_VERTEX_COLORS)]
public static void MenuSetVertexColorPreset0() {
pb_Vertex_Color_Toolbar.SetFaceColors(0);
}
#endregion
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a241196dd31138e4ca612fcf4c3e07ca
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,497 @@
/**
* Repairs missing pb_Object and pb_Entity references. It is based
* on this article by Unity Gems: http://unitygems.com/lateral1/
*/
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.Linq;
using ProBuilder2.Common;
using ProBuilder2.MeshOperations;
namespace ProBuilder2.EditorCommon
{
/**
* Extends MonoBehaviour Inspector, automatically fixing missing script
* references (typically caused by ProBuilder upgrade process).
*/
[CustomEditor(typeof(MonoBehaviour))]
public class pb_MissingScriptEditor : Editor
{
#region Members
static bool applyDummyScript = true; ///< If true, any null components that can't be set will have this script applied to their reference, allowing us to later remove them.
static float index = 0; ///< general idea of where we are in terms of processing this scene.
static float total; ///< general idea of how many missing script references are in this scene.
static bool doFix = false; ///< while true, the inspector will attempt to cycle to broken gameobjects until none are found.
static List<GameObject> unfixable = new List<GameObject>(); ///< if a non-pb missing reference is encountered, need to let the iterator know not to bother,
static MonoScript _mono_pb; ///< MonoScript assets
static MonoScript _mono_pe; ///< MonoScript assets
static MonoScript _mono_dummy; ///< MonoScript assets
/**
* Load the pb_Object and pb_Entity classes to MonoScript assets. Saves us from having to fall back on Reflection.
*/
static void LoadMonoScript()
{
GameObject go = new GameObject();
pb_Object pb = go.AddComponent<pb_Object>();
pb_Entity pe = go.GetComponent<pb_Entity>();
if(pe == null)
pe = go.AddComponent<pb_Entity>();
pb_DummyScript du = go.AddComponent<pb_DummyScript>();
_mono_pb = MonoScript.FromMonoBehaviour( pb );
_mono_pe = MonoScript.FromMonoBehaviour( pe );
_mono_dummy = MonoScript.FromMonoBehaviour( du );
DestroyImmediate(go);
}
public MonoScript pb_monoscript
{
get
{
if(_mono_pb == null) LoadMonoScript();
return _mono_pb;
}
}
public MonoScript pe_monoscript
{
get
{
if(_mono_pe == null) LoadMonoScript();
return _mono_pe;
}
}
public MonoScript dummy_monoscript
{
get
{
if(_mono_dummy == null) LoadMonoScript();
return _mono_dummy;
}
}
#endregion
[MenuItem("Tools/" + pb_Constant.PRODUCT_NAME + "/Repair/Repair Missing Script References")]
public static void MenuRepairMissingScriptReferences()
{
FixAllScriptReferencesInScene();
}
static void FixAllScriptReferencesInScene()
{
EditorApplication.ExecuteMenuItem("Window/Inspector");
Object[] all = Resources.FindObjectsOfTypeAll(typeof(GameObject)).Where(x => ((GameObject)x).GetComponents<Component>().Any(n => n == null) ).ToArray();
total = all.Length;
unfixable.Clear();
if(total > 1)
{
Undo.RecordObjects(all, "Fix missing script references");
index = 0;
doFix = true;
Next();
}
else
{
if( applyDummyScript )
DeleteDummyScripts();
EditorUtility.DisplayDialog("Success", "No missing ProBuilder script references found.", "Okay");
}
}
/**
* Advance to the next gameobject with missing components. If none are found, display dialog and exit.
*/
static void Next()
{
bool earlyExit = false;
if( EditorUtility.DisplayCancelableProgressBar("Repair ProBuilder Script References", "Fixing " + (int)Mathf.Floor(index+1) + " out of " + total + " objects in scene.", ((float)index/total) ) )
{
earlyExit = true;
doFix = false;
}
if(!earlyExit)
{
// Cycle through FindObjectsOfType on every Next() because using a static list didn't work for some reason.
foreach(GameObject go in Resources.FindObjectsOfTypeAll(typeof(GameObject)))
{
if(go.GetComponents<Component>().Any(x => x == null) && !unfixable.Contains(go))
{
if( (PrefabUtility.GetPrefabType(go) == PrefabType.PrefabInstance ||
PrefabUtility.GetPrefabType(go) == PrefabType.Prefab ) )
{
GameObject pref = (GameObject)PrefabUtility.GetPrefabParent(go);
if(pref && (pref.GetComponent<pb_Object>() || pref.GetComponent<pb_Entity>()))
{
unfixable.Add(go);
continue;
}
}
if(go.hideFlags != HideFlags.None)
{
unfixable.Add(go);
continue;
}
Selection.activeObject = go;
return;
}
}
}
pb_Object[] pbs = (pb_Object[])Resources.FindObjectsOfTypeAll(typeof(pb_Object));
for(int i = 0; i < pbs.Length; i++)
{
EditorUtility.DisplayProgressBar("Checking ProBuilder Meshes", "Refresh " + (i+1) + " out of " + total + " objects in scene.", ((float)i/pbs.Length) );
try
{
pbs[i].ToMesh();
pbs[i].Refresh();
pbs[i].Optimize();
} catch (System.Exception e)
{
Debug.LogWarning("Failed reconstituting " + pbs[i].name + ". Proceeding with upgrade anyways. Usually this means a prefab is already fixed, and just needs to be instantiated to take effect.\n" + e.ToString());
}
}
EditorUtility.ClearProgressBar();
if( applyDummyScript )
DeleteDummyScripts();
EditorUtility.DisplayDialog("Success", "Successfully repaired " + total + " ProBuilder objects.", "Okay");
if(!pb_EditorSceneUtility.SaveCurrentSceneIfUserWantsTo())
Debug.LogWarning("Repaired script references will be lost on exit if this scene is not saved!");
doFix = false;
skipEvent = true;
}
/**
* SerializedProperty names found in pb_Entity.
*/
List<string> PB_OBJECT_SCRIPT_PROPERTIES = new List<string>()
{
"_sharedIndices",
"_vertices",
"_uv",
"_sharedIndicesUV",
"_quads"
};
/**
* SerializedProperty names found in pb_Object.
*/
List<string> PB_ENTITY_SCRIPT_PROPERTIES = new List<string>()
{
"pb",
"userSetDimensions",
"_entityType",
"forceConvex"
};
// Prevents ArgumentException after displaying 'Done' dialog. For some reason the Event loop skips layout phase after DisplayDialog.
private static bool skipEvent = false;
public override void OnInspectorGUI()
{
if(skipEvent && Event.current.type == EventType.Repaint)
{
skipEvent = false;
return;
}
SerializedProperty scriptProperty = this.serializedObject.FindProperty("m_Script");
if(scriptProperty == null || scriptProperty.objectReferenceValue != null)
{
if(doFix)
{
if(Event.current.type == EventType.Repaint)
{
Next();
}
}
else
{
base.OnInspectorGUI();
}
return;
}
int pbObjectMatches = 0, pbEntityMatches = 0;
// Shows a detailed tree view of all the properties in this serializedobject.
// GUILayout.Label( SerializedObjectToString(this.serializedObject) );
SerializedProperty iterator = this.serializedObject.GetIterator();
iterator.Next(true);
while( iterator.Next(true) )
{
if( PB_OBJECT_SCRIPT_PROPERTIES.Contains(iterator.name) )
pbObjectMatches++;
if( PB_ENTITY_SCRIPT_PROPERTIES.Contains(iterator.name) )
pbEntityMatches++;
}
// If we can fix it, show the help box, otherwise just default inspector it up.
if(pbObjectMatches >= 3 || pbEntityMatches >= 3)
{
EditorGUILayout.HelpBox("Missing Script Reference\n\nProBuilder can automatically fix this missing reference. To fix all references in the scene, click \"Fix All in Scene\". To fix just this one, click \"Reconnect\".", MessageType.Warning);
}
else
{
if(doFix)
{
if( applyDummyScript )
{
index += .5f;
scriptProperty.objectReferenceValue = dummy_monoscript;
scriptProperty.serializedObject.ApplyModifiedProperties();
scriptProperty = this.serializedObject.FindProperty("m_Script");
scriptProperty.serializedObject.Update();
}
else
{
unfixable.Add( ((Component)target).gameObject );
}
Next();
GUIUtility.ExitGUI();
return;
}
else
{
base.OnInspectorGUI();
}
return;
}
GUI.backgroundColor = Color.green;
if(!doFix)
{
if(GUILayout.Button("Fix All in Scene"))
{
FixAllScriptReferencesInScene();
return;
}
}
GUI.backgroundColor = Color.cyan;
if((doFix && Event.current.type == EventType.Repaint) || GUILayout.Button("Reconnect"))
{
if(pbObjectMatches >= 3) // only increment for pb_Object otherwise the progress bar will fill 2x faster than it should
{
index++;
}
else
{
// Make sure that pb_Object is fixed first if we're automatically cycling objects.
if(doFix && ((Component)target).gameObject.GetComponent<pb_Object>() == null)
return;
}
if(!doFix)
{
Undo.RegisterCompleteObjectUndo(target, "Fix missing reference.");
}
// Debug.Log("Fix: " + (pbObjectMatches > 2 ? "pb_Object" : "pb_Entity") + " " + ((Component)target).gameObject.name);
scriptProperty.objectReferenceValue = pbObjectMatches >= 3 ? pb_monoscript : pe_monoscript;
scriptProperty.serializedObject.ApplyModifiedProperties();
scriptProperty = this.serializedObject.FindProperty("m_Script");
scriptProperty.serializedObject.Update();
if(doFix)
Next();
GUIUtility.ExitGUI();
}
GUI.backgroundColor = Color.white;
}
/**
* Scan the scene for gameObjects referencing `pb_DummyScript` and delete them.
*/
static void DeleteDummyScripts()
{
pb_DummyScript[] dummies = (pb_DummyScript[])Resources.FindObjectsOfTypeAll(typeof(pb_DummyScript));
dummies = dummies.Where(x => x.hideFlags == HideFlags.None).ToArray();
if(dummies.Length > 0)
{
int ret = EditorUtility.DisplayDialogComplex("Found Unrepairable Objects", "Repair script found " + dummies.Length + " missing components that could not be repaired. Would you like to delete those components now, or attempt to rebuild (ProBuilderize) them?", "Delete", "Cancel", "ProBuilderize");
switch(ret)
{
case 1: // cancel
{}
break;
default:
{
// Delete and ProBuilderize
if(ret == 2)
{
// Only interested in objects that have 2 null components (pb_Object and pb_Entity)
Object[] broken = (Object[])Resources.FindObjectsOfTypeAll(typeof(GameObject))
.Where(x => !x.Equals(null) &&
x is GameObject &&
((GameObject)x).GetComponents<pb_DummyScript>().Length == 2 &&
((GameObject)x).GetComponent<MeshRenderer>() != null &&
((GameObject)x).GetComponent<MeshFilter>() != null &&
((GameObject)x).GetComponent<MeshFilter>().sharedMesh != null
).ToArray();
broken = broken.Distinct().ToArray();
ProBuilder2.Actions.ProBuilderize.DoProBuilderize(
System.Array.ConvertAll(broken, x => (GameObject) x)
.Select(x => x.GetComponent<MeshFilter>()),
pb_MeshImporter.Settings.Default);
}
// Always delete components
Undo.RecordObjects(dummies.Select(x=>x.gameObject).ToArray(), "Delete Broken Scripts");
for(int i = 0; i < dummies.Length; i++)
GameObject.DestroyImmediate( dummies[i] );
}
break;
}
}
}
/**
* Returns a formatted string with all properties in serialized object.
*/
static string SerializedObjectToString(SerializedObject serializedObject)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if(serializedObject == null)
{
sb.Append("NULL");
return sb.ToString();
}
SerializedProperty iterator = serializedObject.GetIterator();
iterator.Next(true);
while( iterator.Next(true) )
{
string tabs = "";
for(int i = 0; i < iterator.depth; i++) tabs += "\t";
sb.AppendLine(tabs + iterator.name + (iterator.propertyType == SerializedPropertyType.ObjectReference && iterator.type.Contains("Component") && iterator.objectReferenceValue == null ? " -> NULL" : "") );
tabs += " - ";
sb.AppendLine(tabs + "Type: (" + iterator.type + " / " + iterator.propertyType + " / " + " / " + iterator.name + ")");
sb.AppendLine(tabs + iterator.propertyPath);
sb.AppendLine(tabs + "Value: " + SerializedPropertyValue(iterator));
}
return sb.ToString();
}
/**
* Return a string from the value of a SerializedProperty.
*/
static string SerializedPropertyValue(SerializedProperty sp)
{
switch(sp.propertyType)
{
case SerializedPropertyType.Integer:
return sp.intValue.ToString();
case SerializedPropertyType.Boolean:
return sp.boolValue.ToString();
case SerializedPropertyType.Float:
return sp.floatValue.ToString();
case SerializedPropertyType.String:
return sp.stringValue.ToString();
case SerializedPropertyType.Color:
return sp.colorValue.ToString();
case SerializedPropertyType.ObjectReference:
return (sp.objectReferenceValue == null ? "null" : sp.objectReferenceValue.name);
case SerializedPropertyType.LayerMask:
return sp.intValue.ToString();
case SerializedPropertyType.Enum:
return sp.enumValueIndex.ToString();
case SerializedPropertyType.Vector2:
return sp.vector2Value.ToString();
case SerializedPropertyType.Vector3:
return sp.vector3Value.ToString();
// Not public api as of 4.3?
// case SerializedPropertyType.Vector4:
// return sp.vector4Value.ToString();
case SerializedPropertyType.Rect:
return sp.rectValue.ToString();
case SerializedPropertyType.ArraySize:
return sp.intValue.ToString();
case SerializedPropertyType.Character:
return "Character";
case SerializedPropertyType.AnimationCurve:
return sp.animationCurveValue.ToString();
case SerializedPropertyType.Bounds:
return sp.boundsValue.ToString();
case SerializedPropertyType.Gradient:
return "Gradient";
default:
return "Unknown type";
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dd8f47a8919189447ad0df151b5d75eb
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,457 @@
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4
#define UNITY_5_4_OR_LOWER
#else
#define UNITY_5_5_OR_HIGHER
#endif
#if UNITY_4_6 || UNITY_4_7 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 || UNITY_5_4 || UNITY_5_5
#define UNITY_5_5_OR_LOWER
#else
#define UNITY_5_6_OR_HIGHER
#endif
using UnityEngine;
using UnityEditor;
using UnityEngine.Rendering;
using ProBuilder2.Common;
using ProBuilder2.EditorCommon;
using System.Linq;
public class pb_Preferences : Editor
{
private static bool prefsLoaded = false;
static Color pbDefaultFaceColor;
static Color pbDefaultEdgeColor;
static Color pbDefaultSelectedVertexColor;
static Color pbDefaultVertexColor;
static bool defaultOpenInDockableWindow;
static Material pbDefaultMaterial;
static Vector2 settingsScroll = Vector2.zero;
static bool pbShowEditorNotifications;
static bool pbForceConvex = false;
static bool pbDragCheckLimit = false;
static bool pbForceVertexPivot = true;
static bool pbForceGridPivot = true;
static bool pbPerimeterEdgeBridgeOnly;
static bool pbPBOSelectionOnly;
static bool pbCloseShapeWindow = false;
static bool pbUVEditorFloating = true;
static bool pbStripProBuilderOnBuild = true;
static bool pbDisableAutoUV2Generation = false;
static bool pbShowSceneInfo = false;
static bool pbUniqueModeShortcuts = false;
static bool pbIconGUI = false;
static bool pbShiftOnlyTooltips = false;
static bool pbDrawAxisLines = true;
static bool pbMeshesAreAssets = false;
static bool pbElementSelectIsHamFisted = false;
static bool pbDragSelectWholeElement = false;
static bool pbEnableExperimental = false;
static bool showMissingLightmapUvWarning = false;
#if !UNITY_4_6 && !UNITY_4_7
static ShadowCastingMode pbShadowCastingMode = ShadowCastingMode.On;
#endif
static ColliderType defaultColliderType = ColliderType.BoxCollider;
static SceneToolbarLocation pbToolbarLocation = SceneToolbarLocation.UpperCenter;
static EntityType pbDefaultEntity = EntityType.Detail;
static float pbUVGridSnapValue;
static float pbVertexHandleSize;
static pb_Shortcut[] defaultShortcuts;
[PreferenceItem(pb_Constant.PRODUCT_NAME)]
private static void PreferencesGUI ()
{
// Load the preferences
if (!prefsLoaded) {
LoadPrefs();
prefsLoaded = true;
}
settingsScroll = EditorGUILayout.BeginScrollView(settingsScroll, GUILayout.MinHeight(180), GUILayout.MaxHeight(180));
EditorGUI.BeginChangeCheck();
if(GUILayout.Button("Reset All Preferences"))
ResetToDefaults();
/**
* GENERAL SETTINGS
*/
GUILayout.Label("General Settings", EditorStyles.boldLabel);
pbStripProBuilderOnBuild = EditorGUILayout.Toggle(new GUIContent("Strip PB Scripts on Build", "If true, when building an executable all ProBuilder scripts will be stripped from your built product."), pbStripProBuilderOnBuild);
pbDisableAutoUV2Generation = EditorGUILayout.Toggle(new GUIContent("Disable Auto UV2 Generation", "Disables automatic generation of UV2 channel. If Unity is sluggish when working with large ProBuilder objects, disabling UV2 generation will improve performance. Use `Actions/Generate UV2` or `Actions/Generate Scene UV2` to build lightmap UVs prior to baking."), pbDisableAutoUV2Generation);
pbShowSceneInfo = EditorGUILayout.Toggle(new GUIContent("Show Scene Info", "Displays the selected object vertex and triangle counts in the scene view."), pbShowSceneInfo);
pbShowEditorNotifications = EditorGUILayout.Toggle("Show Editor Notifications", pbShowEditorNotifications);
/**
* TOOLBAR SETTINGS
*/
GUILayout.Label("Toolbar Settings", EditorStyles.boldLabel);
pbIconGUI = EditorGUILayout.Toggle(new GUIContent("Use Icon GUI", "Toggles the ProBuilder window interface between text and icon versions."), pbIconGUI);
pbShiftOnlyTooltips = EditorGUILayout.Toggle(new GUIContent("Shift Key Tooltips", "Tooltips will only show when the Shift key is held"), pbShiftOnlyTooltips);
pbToolbarLocation = (SceneToolbarLocation) EditorGUILayout.EnumPopup("Toolbar Location", pbToolbarLocation);
pbUniqueModeShortcuts = EditorGUILayout.Toggle(new GUIContent("Unique Mode Shortcuts", "When off, the G key toggles between Object and Element modes and H enumerates the element modes. If on, G, H, J, and K are shortcuts to Object, Vertex, Edge, and Face modes respectively."), pbUniqueModeShortcuts);
defaultOpenInDockableWindow = EditorGUILayout.Toggle("Open in Dockable Window", defaultOpenInDockableWindow);
/**
* DEFAULT SETTINGS
*/
GUILayout.Label("Defaults", EditorStyles.boldLabel);
pbDefaultMaterial = (Material) EditorGUILayout.ObjectField("Default Material", pbDefaultMaterial, typeof(Material), false);
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Default Entity");
pbDefaultEntity = ((EntityType)EditorGUILayout.EnumPopup( (EntityType)pbDefaultEntity ));
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Default Collider");
defaultColliderType = ((ColliderType)EditorGUILayout.EnumPopup( (ColliderType)defaultColliderType ));
GUILayout.EndHorizontal();
if((ColliderType)defaultColliderType == ColliderType.MeshCollider)
pbForceConvex = EditorGUILayout.Toggle("Force Convex Mesh Collider", pbForceConvex);
#if !UNITY_4_6 && !UNITY_4_7
GUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Shadow Casting Mode");
pbShadowCastingMode = (ShadowCastingMode) EditorGUILayout.EnumPopup(pbShadowCastingMode);
GUILayout.EndHorizontal();
#endif
/**
* MISC. SETTINGS
*/
GUILayout.Label("Misc. Settings", EditorStyles.boldLabel);
pbDragCheckLimit = EditorGUILayout.Toggle(new GUIContent("Limit Drag Check to Selection", "If true, when drag selecting faces, only currently selected pb-Objects will be tested for matching faces. If false, all pb_Objects in the scene will be checked. The latter may be slower in large scenes."), pbDragCheckLimit);
pbPBOSelectionOnly = EditorGUILayout.Toggle(new GUIContent("Only PBO are Selectable", "If true, you will not be able to select non probuilder objects in Geometry and Texture mode"), pbPBOSelectionOnly);
pbCloseShapeWindow = EditorGUILayout.Toggle(new GUIContent("Close shape window after building", "If true the shape window will close after hitting the build button"), pbCloseShapeWindow);
pbDrawAxisLines = EditorGUILayout.Toggle(new GUIContent("Dimension Overlay Lines", "When the Dimensions Overlay is on, this toggle shows or hides the axis lines."), pbDrawAxisLines);
showMissingLightmapUvWarning = EditorGUILayout.Toggle("Show Missing Lightmap UVs Warning", showMissingLightmapUvWarning);
GUILayout.Space(4);
/**
* GEOMETRY EDITING SETTINGS
*/
GUILayout.Label("Geometry Editing Settings", EditorStyles.boldLabel);
pbElementSelectIsHamFisted = !EditorGUILayout.Toggle(new GUIContent("Precise Element Selection", "When enabled you will be able to select object faces when in Vertex of Edge mode by clicking the center of a face. When disabled, edge and vertex selection will always be restricted to the nearest element."), !pbElementSelectIsHamFisted);
pbDragSelectWholeElement = EditorGUILayout.Toggle("Precise Drag Select", pbDragSelectWholeElement);
pbDefaultFaceColor = EditorGUILayout.ColorField("Selected Face Color", pbDefaultFaceColor);
pbDefaultEdgeColor = EditorGUILayout.ColorField("Edge Wireframe Color", pbDefaultEdgeColor);
pbDefaultVertexColor = EditorGUILayout.ColorField("Vertex Color", pbDefaultVertexColor);
pbDefaultSelectedVertexColor = EditorGUILayout.ColorField("Selected Vertex Color", pbDefaultSelectedVertexColor);
pbVertexHandleSize = EditorGUILayout.Slider("Vertex Handle Size", pbVertexHandleSize, 0f, 3f);
pbForceVertexPivot = EditorGUILayout.Toggle(new GUIContent("Force Pivot to Vertex Point", "If true, new objects will automatically have their pivot point set to a vertex instead of the center."), pbForceVertexPivot);
pbForceGridPivot = EditorGUILayout.Toggle(new GUIContent("Force Pivot to Grid", "If true, newly instantiated pb_Objects will be snapped to the nearest point on grid. If ProGrids is present, the snap value will be used, otherwise decimals are simply rounded to whole numbers."), pbForceGridPivot);
pbPerimeterEdgeBridgeOnly = EditorGUILayout.Toggle(new GUIContent("Bridge Perimeter Edges Only", "If true, only edges on the perimeters of an object may be bridged. If false, you may bridge any between any two edges you like."), pbPerimeterEdgeBridgeOnly);
GUILayout.Space(4);
GUILayout.Label("Experimental", EditorStyles.boldLabel);
pbEnableExperimental = EditorGUILayout.Toggle(new GUIContent("Experimental Features", "Enables some experimental new features that we're trying out. These may be incomplete or buggy, so please exercise caution when making use of this functionality!"), pbEnableExperimental);
pbMeshesAreAssets = EditorGUILayout.Toggle(new GUIContent("Meshes Are Assets", "Experimental! Instead of storing mesh data in the scene, this toggle creates a Mesh cache in the Project that ProBuilder will use."), pbMeshesAreAssets);
GUILayout.Space(4);
/**
* UV EDITOR SETTINGS
*/
GUILayout.Label("UV Editing Settings", EditorStyles.boldLabel);
pbUVGridSnapValue = EditorGUILayout.FloatField("UV Snap Increment", pbUVGridSnapValue);
pbUVGridSnapValue = Mathf.Clamp(pbUVGridSnapValue, .015625f, 2f);
pbUVEditorFloating = EditorGUILayout.Toggle(new GUIContent("Editor window floating", "If true UV Editor window will open as a floating window"), pbUVEditorFloating);
EditorGUILayout.EndScrollView();
GUILayout.Space(4);
GUILayout.Label("Shortcut Settings", EditorStyles.boldLabel);
ShortcutSelectPanel();
ShortcutEditPanel();
// Save the preferences
if (EditorGUI.EndChangeCheck())
SetPrefs();
}
public static void ResetToDefaults()
{
if(EditorUtility.DisplayDialog("Delete ProBuilder editor preferences?", "Are you sure you want to delete all existing ProBuilder preferences?\n\nThis action cannot be undone.", "Yes", "No"))
{
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultFaceColor);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultEditLevel);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultSelectionMode);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbHandleAlignment);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbVertexColorTool);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbToolbarLocation);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultEntity);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultFaceColor);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultEdgeColor);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultSelectedVertexColor);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultVertexColor);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultOpenInDockableWindow);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbEditorPrefVersion);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbEditorShortcutsVersion);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultCollider);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbForceConvex);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbVertexColorPrefs);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowEditorNotifications);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDragCheckLimit);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbForceVertexPivot);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbForceGridPivot);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbManifoldEdgeExtrusion);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbPerimeterEdgeBridgeOnly);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbPBOSelectionOnly);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbCloseShapeWindow);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbUVEditorFloating);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbUVMaterialPreview);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowSceneToolbar);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbNormalizeUVsOnPlanarProjection);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbStripProBuilderOnBuild);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDisableAutoUV2Generation);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowSceneInfo);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbEnableBackfaceSelection);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbVertexPaletteDockable);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbExtrudeAsGroup);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbUniqueModeShortcuts);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbMaterialEditorFloating);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShapeWindowFloating);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbIconGUI);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShiftOnlyTooltips);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDrawAxisLines);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbCollapseVertexToFirst);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbMeshesAreAssets);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbElementSelectIsHamFisted);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDragSelectWholeElement);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbEnableExperimental);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbFillHoleSelectsEntirePath);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDetachToNewObject);
#pragma warning disable 0618
pb_PreferencesInternal.DeleteKey(pb_Constant.pbPreserveFaces);
#pragma warning restore 0618
pb_PreferencesInternal.DeleteKey(pb_Constant.pbVertexHandleSize);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbUVGridSnapValue);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbUVWeldDistance);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbWeldDistance);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbExtrudeDistance);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbBevelAmount);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbEdgeSubdivisions);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultShortcuts);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbDefaultMaterial);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbGrowSelectionUsingAngle);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbGrowSelectionAngle);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbGrowSelectionAngleIterative);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowDetail);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowOccluder);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowMover);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowCollider);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowTrigger);
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShowNoDraw);
pb_PreferencesInternal.DeleteKey("pb_Lightmapping::showMissingLightmapUvWarning");
#if !UNITY_4_6 && !UNITY_4_7
pb_PreferencesInternal.DeleteKey(pb_Constant.pbShadowCastingMode);
#endif
}
LoadPrefs();
}
static int shortcutIndex = 0;
#if UNITY_5_6_OR_HIGHER
static Rect selectBox = new Rect(0, 214, 183, 156);
static Rect shortcutEditRect = new Rect(190, 191, 178, 300);
#else
static Rect selectBox = new Rect(130, 253, 183, 142);
static Rect shortcutEditRect = new Rect(320, 228, 178, 300);
#endif
static Vector2 shortcutScroll = Vector2.zero;
static int CELL_HEIGHT = 20;
static void ShortcutSelectPanel()
{
GUILayout.Space(4);
GUI.contentColor = Color.white;
GUI.Box(selectBox, "");
GUIStyle labelStyle = GUIStyle.none;
if(EditorGUIUtility.isProSkin)
labelStyle.normal.textColor = new Color(1f, 1f, 1f, .8f);
labelStyle.alignment = TextAnchor.MiddleLeft;
labelStyle.contentOffset = new Vector2(4f, 0f);
shortcutScroll = EditorGUILayout.BeginScrollView(shortcutScroll, false, true, GUILayout.MaxWidth(183), GUILayout.MaxHeight(156));
for(int n = 1; n < defaultShortcuts.Length; n++)
{
if(n == shortcutIndex)
{
GUI.backgroundColor = new Color(0.23f, .49f, .89f, 1f);
labelStyle.normal.background = EditorGUIUtility.whiteTexture;
Color oc = labelStyle.normal.textColor;
labelStyle.normal.textColor = Color.white;
GUILayout.Box(defaultShortcuts[n].action, labelStyle, GUILayout.MinHeight(CELL_HEIGHT), GUILayout.MaxHeight(CELL_HEIGHT));
labelStyle.normal.background = null;
labelStyle.normal.textColor = oc;
GUI.backgroundColor = Color.white;
}
else
{
if(GUILayout.Button(defaultShortcuts[n].action, labelStyle, GUILayout.MinHeight(CELL_HEIGHT), GUILayout.MaxHeight(CELL_HEIGHT)))
{
shortcutIndex = n;
}
}
}
EditorGUILayout.EndScrollView();
}
static void ShortcutEditPanel()
{
GUILayout.BeginArea(shortcutEditRect);
// descriptionTitleRect = EditorGUI.RectField(new Rect(240,150,200,50), descriptionTitleRect);
GUILayout.Label("Key", EditorStyles.boldLabel);
KeyCode key = defaultShortcuts[shortcutIndex].key;
key = (KeyCode) EditorGUILayout.EnumPopup(key);
defaultShortcuts[shortcutIndex].key = key;
GUILayout.Label("Modifiers", EditorStyles.boldLabel);
// EnumMaskField returns a bit-mask where the flags correspond to the indices of the enum, not the enum values,
// so this isn't technically correct.
#if UNITY_2017_3_OR_NEWER
EventModifiers em = (EventModifiers) defaultShortcuts[shortcutIndex].eventModifiers;
defaultShortcuts[shortcutIndex].eventModifiers = (EventModifiers) EditorGUILayout.EnumFlagsField(em);
#else
EventModifiers em = (EventModifiers) (((int)defaultShortcuts[shortcutIndex].eventModifiers) * 2);
em = (EventModifiers)EditorGUILayout.EnumMaskField(em);
defaultShortcuts[shortcutIndex].eventModifiers = (EventModifiers) (((int)em) / 2);
#endif
GUILayout.Label("Description", EditorStyles.boldLabel);
GUILayout.Label(defaultShortcuts[shortcutIndex].description, EditorStyles.wordWrappedLabel);
GUILayout.EndArea();
}
static void LoadPrefs()
{
pbStripProBuilderOnBuild = pb_PreferencesInternal.GetBool(pb_Constant.pbStripProBuilderOnBuild);
pbDisableAutoUV2Generation = pb_PreferencesInternal.GetBool(pb_Constant.pbDisableAutoUV2Generation);
pbShowSceneInfo = pb_PreferencesInternal.GetBool(pb_Constant.pbShowSceneInfo);
defaultOpenInDockableWindow = pb_PreferencesInternal.GetBool(pb_Constant.pbDefaultOpenInDockableWindow);
pbDragCheckLimit = pb_PreferencesInternal.GetBool(pb_Constant.pbDragCheckLimit);
pbForceConvex = pb_PreferencesInternal.GetBool(pb_Constant.pbForceConvex);
pbForceGridPivot = pb_PreferencesInternal.GetBool(pb_Constant.pbForceGridPivot);
pbForceVertexPivot = pb_PreferencesInternal.GetBool(pb_Constant.pbForceVertexPivot);
pbPerimeterEdgeBridgeOnly = pb_PreferencesInternal.GetBool(pb_Constant.pbPerimeterEdgeBridgeOnly);
pbPBOSelectionOnly = pb_PreferencesInternal.GetBool(pb_Constant.pbPBOSelectionOnly);
pbCloseShapeWindow = pb_PreferencesInternal.GetBool(pb_Constant.pbCloseShapeWindow);
pbUVEditorFloating = pb_PreferencesInternal.GetBool(pb_Constant.pbUVEditorFloating);
// pbShowSceneToolbar = pb_Preferences_Internal.GetBool(pb_Constant.pbShowSceneToolbar);
pbShowEditorNotifications = pb_PreferencesInternal.GetBool(pb_Constant.pbShowEditorNotifications);
pbUniqueModeShortcuts = pb_PreferencesInternal.GetBool(pb_Constant.pbUniqueModeShortcuts);
pbIconGUI = pb_PreferencesInternal.GetBool(pb_Constant.pbIconGUI);
pbShiftOnlyTooltips = pb_PreferencesInternal.GetBool(pb_Constant.pbShiftOnlyTooltips);
pbDrawAxisLines = pb_PreferencesInternal.GetBool(pb_Constant.pbDrawAxisLines);
pbMeshesAreAssets = pb_PreferencesInternal.GetBool(pb_Constant.pbMeshesAreAssets);
pbElementSelectIsHamFisted = pb_PreferencesInternal.GetBool(pb_Constant.pbElementSelectIsHamFisted);
pbDragSelectWholeElement = pb_PreferencesInternal.GetBool(pb_Constant.pbDragSelectWholeElement);
pbEnableExperimental = pb_PreferencesInternal.GetBool(pb_Constant.pbEnableExperimental);
showMissingLightmapUvWarning = pb_PreferencesInternal.GetBool("pb_Lightmapping::showMissingLightmapUvWarning", false);
pbDefaultFaceColor = pb_PreferencesInternal.GetColor( pb_Constant.pbDefaultFaceColor );
pbDefaultEdgeColor = pb_PreferencesInternal.GetColor( pb_Constant.pbDefaultEdgeColor );
pbDefaultSelectedVertexColor = pb_PreferencesInternal.GetColor( pb_Constant.pbDefaultSelectedVertexColor );
pbDefaultVertexColor = pb_PreferencesInternal.GetColor( pb_Constant.pbDefaultVertexColor );
pbUVGridSnapValue = pb_PreferencesInternal.GetFloat(pb_Constant.pbUVGridSnapValue);
pbVertexHandleSize = pb_PreferencesInternal.GetFloat(pb_Constant.pbVertexHandleSize);
defaultColliderType = pb_PreferencesInternal.GetEnum<ColliderType>(pb_Constant.pbDefaultCollider);
pbToolbarLocation = pb_PreferencesInternal.GetEnum<SceneToolbarLocation>(pb_Constant.pbToolbarLocation);
pbDefaultEntity = pb_PreferencesInternal.GetEnum<EntityType>(pb_Constant.pbDefaultEntity);
#if !UNITY_4_6 && !UNITY_4_7
pbShadowCastingMode = pb_PreferencesInternal.GetEnum<ShadowCastingMode>(pb_Constant.pbShadowCastingMode);
#endif
pbDefaultMaterial = pb_PreferencesInternal.GetMaterial(pb_Constant.pbDefaultMaterial);
defaultShortcuts = pb_PreferencesInternal.GetShortcuts().ToArray();
}
public static void SetPrefs()
{
pb_PreferencesInternal.SetBool (pb_Constant.pbStripProBuilderOnBuild, pbStripProBuilderOnBuild);
pb_PreferencesInternal.SetBool (pb_Constant.pbDisableAutoUV2Generation, pbDisableAutoUV2Generation);
pb_PreferencesInternal.SetBool (pb_Constant.pbShowSceneInfo, pbShowSceneInfo, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetInt (pb_Constant.pbToolbarLocation, (int) pbToolbarLocation, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetInt (pb_Constant.pbDefaultEntity, (int) pbDefaultEntity);
pb_PreferencesInternal.SetColor (pb_Constant.pbDefaultFaceColor, pbDefaultFaceColor, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetColor (pb_Constant.pbDefaultEdgeColor, pbDefaultEdgeColor, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetColor (pb_Constant.pbDefaultSelectedVertexColor, pbDefaultSelectedVertexColor, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetColor (pb_Constant.pbDefaultVertexColor, pbDefaultVertexColor, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetString (pb_Constant.pbDefaultShortcuts, pb_Shortcut.ShortcutsToString(defaultShortcuts), pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetMaterial(pb_Constant.pbDefaultMaterial, pbDefaultMaterial);
pb_PreferencesInternal.SetInt (pb_Constant.pbDefaultCollider, (int) defaultColliderType);
#if !UNITY_4_6 && !UNITY_4_7
pb_PreferencesInternal.SetInt (pb_Constant.pbShadowCastingMode, (int) pbShadowCastingMode);
#endif
pb_PreferencesInternal.SetBool (pb_Constant.pbDefaultOpenInDockableWindow, defaultOpenInDockableWindow, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbShowEditorNotifications, pbShowEditorNotifications, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbForceConvex, pbForceConvex);
pb_PreferencesInternal.SetBool (pb_Constant.pbDragCheckLimit, pbDragCheckLimit, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbForceVertexPivot, pbForceVertexPivot, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbForceGridPivot, pbForceGridPivot, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbPerimeterEdgeBridgeOnly, pbPerimeterEdgeBridgeOnly, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbPBOSelectionOnly, pbPBOSelectionOnly, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbCloseShapeWindow, pbCloseShapeWindow, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbUVEditorFloating, pbUVEditorFloating, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbUniqueModeShortcuts, pbUniqueModeShortcuts, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbIconGUI, pbIconGUI, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbShiftOnlyTooltips, pbShiftOnlyTooltips, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbDrawAxisLines, pbDrawAxisLines, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbMeshesAreAssets, pbMeshesAreAssets);
pb_PreferencesInternal.SetBool (pb_Constant.pbElementSelectIsHamFisted, pbElementSelectIsHamFisted, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbDragSelectWholeElement, pbDragSelectWholeElement, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool (pb_Constant.pbEnableExperimental, pbEnableExperimental, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetBool ("pb_Lightmapping::showMissingLightmapUvWarning", showMissingLightmapUvWarning, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetFloat (pb_Constant.pbVertexHandleSize, pbVertexHandleSize, pb_PreferenceLocation.Global);
pb_PreferencesInternal.SetFloat (pb_Constant.pbUVGridSnapValue, pbUVGridSnapValue, pb_PreferenceLocation.Global);
if(pb_Editor.instance != null)
pb_Editor.instance.OnEnable();
SceneView.RepaintAll();
}
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0e173da316764614aa781d9323718eca
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}

View File

@@ -0,0 +1,73 @@
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using ProBuilder2.Common;
using ProBuilder2.MeshOperations;
using System.Linq;
namespace ProBuilder2.EditorCommon
{
/**
* When building the project, remove all references to pb_Objects.
*/
public class pb_ScenePostProcessor
{
[PostProcessScene]
public static void OnPostprocessScene()
{
Material invisibleFaceMaterial = (Material)Resources.Load("Materials/InvisibleFace");
/**
* Hide nodraw faces if present.
*/
foreach(pb_Object pb in GameObject.FindObjectsOfType(typeof(pb_Object)))
{
if(pb.GetComponent<MeshRenderer>() == null)
continue;
if( pb.GetComponent<MeshRenderer>().sharedMaterials.Any(x => x != null && x.name.Contains("NoDraw")) )
{
Material[] mats = pb.GetComponent<MeshRenderer>().sharedMaterials;
for(int i = 0; i < mats.Length; i++)
{
if(mats[i].name.Contains("NoDraw"))
mats[i] = invisibleFaceMaterial;
}
pb.GetComponent<MeshRenderer>().sharedMaterials = mats;
}
}
if(EditorApplication.isPlayingOrWillChangePlaymode)
return;
foreach(pb_Object pb in GameObject.FindObjectsOfType(typeof(pb_Object)))
{
GameObject go = pb.gameObject;
pb_Entity entity = pb.gameObject.GetComponent<pb_Entity>();
if( entity == null )
continue;
if(entity.entityType == EntityType.Collider || entity.entityType == EntityType.Trigger)
go.GetComponent<MeshRenderer>().enabled = false;
// clear hideflags on prefab meshes
if(pb.msh != null)
pb.msh.hideFlags = HideFlags.None;
if(!pb_PreferencesInternal.GetBool(pb_Constant.pbStripProBuilderOnBuild))
return;
pb.dontDestroyMeshOnDelete = true;
GameObject.DestroyImmediate( pb );
GameObject.DestroyImmediate( go.GetComponent<pb_Entity>() );
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0750965282433464f88a4f9ac7b54b3f
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: