This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def export_single_action(context, filepath): | |
armature = bpy.context.active_object | |
action = armature.animation_data.action | |
scene = bpy.context.scene | |
export_action_internal(context, armature, action, scene, filepath) | |
def export_all_actions(context, filepath): | |
start_time = time.clock() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void SetGameObjectIcon(GameObject go, string texturePath) | |
{ | |
Texture2D texture = AssetDatabase.LoadAssetAtPath<Texture2D>(texturePath); | |
if (texture == null) | |
{ | |
Debug.LogError("Couldn't find an icon..."); | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CustomEditor(typeof(SomeScript))] | |
public class SomeScriptInspector : Editor | |
{ | |
private SomeScript Target; | |
private MaterialEditor _materialEditor; | |
private void OnEnable() | |
{ | |
Target = target as SomeScript; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for blender | |
# resets the radius used by the skin modifier to the desired value | |
import bpy | |
import math | |
def set_all_vertex_skin_radius(obj, radius): | |
for v in obj.data.skin_vertices: | |
for d in v.data: | |
d.radius = (radius,radius) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_non_unwrapped_faces(bm, select = False): | |
uv_layer = bm.loops.layers.uv.verify() | |
bm.faces.layers.tex.verify() # currently blender needs both layers. | |
found = [] | |
zero = Vector((0,0)) | |
for f in bm.faces: | |
totalpos = Vector((0,0)) | |
for l in f.loops: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
/// <summary> | |
/// Provides means to deep-copy a TerrainData object because Unitys' built-in "Instantiate" method | |
/// will miss some things and the resulting copy still shares data with the original. | |
/// </summary> | |
public class TerrainDataCloner | |
{ | |
/// <summary> | |
/// Creates a real deep-copy of a TerrainData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<T> OrderByPositionInHierarchy<T>(this IEnumerable<T> enumerable) where T : Component | |
{ | |
return enumerable.OrderBy(comp => new HierarchySortable(comp.gameObject)); | |
} | |
/// <summary> | |
/// Sorts a list of gameobjects by their position in the hierarchy (top to bottom as if the entire hierarchy is expanded) | |
/// Example: sortedGameobjects = unsortedGameobjects.OrderBy(go => new HierarchySortable(go)).ToList(); | |
/// </summary> | |
public struct HierarchySortable : IComparable<HierarchySortable> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymxs | |
def delete_hidden_children_of(obj): | |
print("Deleting hidden children of " + obj.name) | |
hidden = [c for c in obj.children if c.isNodeHidden] | |
for i in range(len(hidden)): | |
pymxs.runtime.delete(hidden[i]) | |