Skip to content

Instantly share code, notes, and snippets.

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()
@Volantk
Volantk / SetIcon.cs
Last active June 20, 2024 13:31
Set GameObject icon in Unity
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;
}
[CustomEditor(typeof(SomeScript))]
public class SomeScriptInspector : Editor
{
private SomeScript Target;
private MaterialEditor _materialEditor;
private void OnEnable()
{
Target = target as SomeScript;
# 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)
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:
@Volantk
Volantk / TerrainDataCloner.cs
Created August 6, 2020 11:57 — forked from Eldoir/TerrainDataCloner.cs
Helper to deep-copy a TerrainData object in Unity3D
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
@Volantk
Volantk / OrderByPositionInHierarchy.cs
Created January 15, 2021 08:22
Unity function for sorting objects by their position in the hierarchy.
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>
@Volantk
Volantk / pymxs: Merge Hierarchies
Last active March 6, 2022 15:38
With 2 objects selected, will merge children of first selected into last selected. Geo will be replaced in objects found in both hierarchies. New objects will be added. Objects no longer found in first selected will be removed from last selected.
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])