public static bool EnablePair(RefPointType refType1, RefPointType refType2) { foreach (RefPointGroup group in refGroups) { if (refType1 == group.type) { foreach (RefPointType type in group.pairs) { if (refType2 == type) { return(true); } } } else if (refType2 == group.type) { foreach (RefPointType type in group.pairs) { if (refType1 == type) { return(true); } } } } return(false); }
public static RefPointType[] GetGroupOfType(RefPointType refType) { List <RefPointType> types = new List <RefPointType>(); types.Add(refType); foreach (RefPointGroup group in refGroups) { if (refType == group.type) { types.AddRange(group.pairs); return(types.ToArray()); } } foreach (RefPointGroup group in refGroups) { foreach (RefPointType type in group.pairs) { if (refType == type) { types.Add(group.type); break; } } } return(types.ToArray()); }
private bool GetRefPointType(string objName, out RefPointType refType) { refType = RefPointType.male; if (!objName.StartsWith("ref_")) { return(false); } string[] strs = objName.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); if (strs.Length < 3) { return(false); } string refStr = strs[1].ToLower(); foreach (RefPointType type in Enum.GetValues(typeof(RefPointType))) { if (refStr.Equals(type.ToString().ToLower())) { refType = type; return(true); } } return(false); }
public static GameObject GetRefPointGameObject(RefPointType refType) { GameObject prefab = Resources.Load <GameObject>("RefPoint/refpoint"); GameObject go = GameObject.Instantiate(prefab); go.name = "refpoint"; string matName = ""; Color color = Color.white; foreach (RefPointGroup group in refGroups) { if (group.type == refType) { matName = group.type.ToString().ToLower(); color = group.color; break; } } foreach (RefPointGroup group in refGroups) { foreach (RefPointType type in group.pairs) { if (type == refType) { matName = group.type.ToString().ToLower(); color = group.color; break; } } } string matPath = "Assets/BlockEditor/Resources/Refpoint/Materials/" + matName + ".mat"; Material mat = AssetDatabase.LoadAssetAtPath <Material>(matPath); if (mat == null) { mat = new Material(Shader.Find("Standard")); mat.color = color; AssetDatabase.CreateAsset(mat, matPath); AssetDatabase.Refresh(); mat = AssetDatabase.LoadAssetAtPath <Material>(matPath); } Renderer renderer = go.GetComponent <Renderer>(); renderer.sharedMaterial = mat; return(go); }
public RefPointGroup(RefPointType type) { this.type = type; switch (type) { case RefPointType.male: { pairs = new[] { RefPointType.female }; color = new Color(0, 0, 1); break; } case RefPointType.male71: { pairs = new[] { RefPointType.female71 }; color = new Color(0, 1, 0); break; } case RefPointType.male34: { pairs = new[] { RefPointType.female34, RefPointType.claw34, RefPointType.cross50 }; color = new Color(0, 1, 1); break; } case RefPointType.axis34: { pairs = new[] { RefPointType.female34, RefPointType.claw34, RefPointType.cross50 }; color = new Color(1, 1, 0); break; } case RefPointType.axis50: { pairs = new[] { RefPointType.hole50, RefPointType.cross50, RefPointType.claw50 }; color = new Color(1, 0, 1); break; } case RefPointType.male50: { pairs = new[] { RefPointType.female50, RefPointType.hole50 }; color = new Color(1, 0, 0); break; } } }
public static bool IsActive(RefPointType type) { foreach (RefPointGroup group in refGroups) { if (group.type == type) { return(IsActive(group)); } foreach (RefPointType pair in group.pairs) { if (pair == type) { if (IsActive(group)) { return(true); } break; } } } return(false); }
public void Init(PEBlockAlign blockAlign, RefPointType pointType) { this.blockAlign = blockAlign; refPointType = pointType; }