public void Clear() { crusher = null; cPos.Clear(); cRot.Clear(); cScl.Clear(); }
public void Set(TransformCrusher crusher, Vector3 position, Element rotation, Vector3 scale) { this.crusher = crusher; this.position = position; this.scale = scale; this.rotation = rotation; }
// Constructor public CompressedMatrix(TransformCrusher crusher, ref CompressedElement cPos, ref CompressedElement cRot, ref CompressedElement cScl, int pBits, int rBits, int sBits) { this.crusher = crusher; this.cPos = cPos; this.cRot = cRot; this.cScl = cScl; }
// Constructor public CompressedMatrix(TransformCrusher crusher, CompressedElement cPos, CompressedElement cRot, CompressedElement cScl) { this.crusher = crusher; this.cPos = cPos; this.cRot = cRot; this.cScl = cScl; }
private void ConnectSharedCaches() { if (masterSharedCrushers.ContainsKey(prefabInstanceId)) { transformCrusher = masterSharedCrushers[prefabInstanceId]; } else { masterSharedCrushers.Add(prefabInstanceId, transformCrusher); } }
private void Awake() { #if PUN_2_OR_NEWER pv = transform.root.GetComponent <Photon.Pun.PhotonView>(); #elif !UNITY_2019_1_OR_NEWER || MIRROR ni = transform.root.GetComponent <NetworkIdentity>(); #endif var itc = transform.root.GetComponent <IHasTransformCrusher>(); if (itc != null) { tc = itc.TC; } }
private void Awake() { #if PUN_2_OR_NEWER pv = GetComponent <Photon.Pun.PhotonView>(); #else ni = GetComponent <NetworkIdentity>(); unetNI = GetComponent <UnityEngine.Networking.NetworkIdentity>(); #endif var itc = transform.root.GetComponent <IHasTransformCrusher>(); if (itc != null) { tc = itc.TC; } }
/// <summary> /// Set Matrix values to the current values of the supplied Rigidbody. Also set the crusher ref. /// </summary> public void Capture(TransformCrusher crusher, Transform transform) { this.crusher = crusher; this.position = transform.position; // Not sure the idea option for scale... lossy or local. this.scale = transform.localScale; if (crusher != null && crusher.RotCrusher != null && crusher.RotCrusher.TRSType == TRSType.Quaternion) { this.rotation = transform.rotation; } else { this.rotation = transform.eulerAngles; } }
private void Start() { var iTC = GetComponent <IHasTransformCrusher>(); if (iTC != null) { tc = GetComponent <IHasTransformCrusher>().TC; } if (!IsMine) { if (rb) { rb.isKinematic = true; } #if !DISABLE_PHYSICS_2D if (rb2D) { rb2D.isKinematic = true; } #endif } }
// Constructor public Matrix(TransformCrusher crusher, Transform transform) { this.crusher = crusher; bool lclpos = (crusher == null || crusher.PosCrusher == null || crusher.PosCrusher.local); this.position = (lclpos) ? transform.localPosition : transform.position; // Not sure the idea option for scale... lossy or local. bool lclscl = (crusher == null || crusher.SclCrusher == null || crusher.SclCrusher.local); this.scale = (lclscl) ? transform.localScale : transform.lossyScale; bool lclrot = (crusher == null || crusher.RotCrusher == null || crusher.RotCrusher.local); if (crusher != null && crusher.RotCrusher != null && crusher.RotCrusher.TRSType == TRSType.Quaternion) { this.rotation = (lclrot) ? transform.localRotation : transform.rotation; } else { this.rotation = (lclrot) ? transform.localEulerAngles : transform.eulerAngles; } }
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { gc.text = label.text; gc.tooltip = label.tooltip; //EditorGUI.BeginProperty(r, label, property); base.OnGUI(r, property, label); EditorGUI.BeginChangeCheck(); //property.serializedObject.ApplyModifiedProperties(); //property.serializedObject.Update(); //haschanged = true; // Hacky way to get the real object TransformCrusher target = (TransformCrusher)DrawerUtils.GetParent(property.FindPropertyRelative("posCrusher")); currentline = r.yMin; SerializedProperty pos = property.FindPropertyRelative("posCrusher"); SerializedProperty rot = property.FindPropertyRelative("rotCrusher"); SerializedProperty scl = property.FindPropertyRelative("sclCrusher"); SerializedProperty isExpanded = property.FindPropertyRelative("isExpanded"); float ph = EditorGUI.GetPropertyHeight(pos); float rh = EditorGUI.GetPropertyHeight(rot); float sh = EditorGUI.GetPropertyHeight(scl); /// Header //bool _isExpanded = GUI.Toggle(new Rect(r.xMin/* - 12*/, currentline, r.width, TITL_HGHT), isExpanded.boolValue, GUIContent.none, (GUIStyle)"Foldout"); bool _isExpanded = EditorGUI.Toggle(new Rect(r.xMin /* - 12*/, currentline, r.width, TITL_HGHT), GUIContent.none, isExpanded.boolValue, (GUIStyle)"Foldout"); if (isExpanded.boolValue != _isExpanded) { isExpanded.boolValue = _isExpanded; property.serializedObject.ApplyModifiedProperties(); } EditorGUI.LabelField(new Rect(r.xMin + 12, currentline, r.width - 64, TITL_HGHT), gc); // property.displayName /*new GUIContent("Transform Crusher " + label)*//*, (GUIStyle)"BoldLabel"*/); //GUI.Label(new Rect(r.xMin + 12, currentline, r.width - 64, TITL_HGHT), gc);// property.displayName /*new GUIContent("Transform Crusher " + label)*//*, (GUIStyle)"BoldLabel"*/); int totalbits = target.TallyBits(); int frag0bits = Mathf.Clamp(totalbits, 0, 64); int frag1bits = Mathf.Clamp(totalbits - 64, 0, 64); int frag2bits = Mathf.Clamp(totalbits - 128, 0, 64); int frag3bits = Mathf.Clamp(totalbits - 192, 0, 64); reusableGC.tooltip = "Total Bits : " + totalbits; sb.Length = 0; sb.Append(frag0bits.ToString()); if (frag1bits > 0) { sb.Append("|").Append(frag1bits); } if (frag2bits > 0) { sb.Append("|").Append(frag2bits); } if (frag3bits > 0) { sb.Append("|").Append(frag3bits); } sb.Append(" bits"); reusableGC.text = sb.ToString(); EditorGUI.LabelField(new Rect(paddedleft, currentline, paddedwidth, 16), reusableGC, miniLabelRight); if (isExpanded.boolValue) { Rect ir = r; // EditorGUI.IndentedRect(r);; ir.yMin = ir.yMin + HEADR_HGHT + 2; ir.xMin -= BOUNDING_PADDING; ir.xMax += BOUNDING_PADDING; ir.yMax -= 6; currentline += BOUNDING_PADDING; //EditorGUI.LabelField(ir, GUIContent.none, /*(GUIStyle)"RectangleToolVBar");// */(GUIStyle)"HelpBox"); ir = EditorGUI.IndentedRect(ir); //ir.xMin += 1; ir.xMax -= 1; //ir.yMin += 1; ir.yMax -= 1; SolidTextures.DrawTexture(ir, SolidTextures.darken202D); /// TRS Element Boxes currentline += TITL_HGHT; //float leftConnectorY = currentline; DrawSet(r, currentline, ph, pos); currentline += ph + SET_PAD; DrawSet(r, currentline, rh, rot); currentline += rh + SET_PAD; DrawSet(r, currentline, sh, scl); currentline += sh /*+ SET_PAD*/; /// Connecting line between TRS Elements //SolidTextures.DrawTexture(new Rect(4, leftConnectorY + 4, 4, currentline - leftConnectorY), SolidTextures.lowcontrast2D); //EditorGUI.LabelField(new Rect(0, leftConnectorY + 4, 4, currentline - leftConnectorY - 12), GUIContent.none, (GUIStyle)"MiniSliderVertical"); } if (EditorGUI.EndChangeCheck()) { property.serializedObject.ApplyModifiedProperties(); } //EditorGUI.EndProperty(); }
public void Set(TransformCrusher crusher, Transform transform) { Capture(crusher, transform); }
// Constructor public Matrix(TransformCrusher crusher) { this.crusher = crusher; }
public void Clear() { this.crusher = null; }
public void Set(TransformCrusher crusher, Rigidbody rb) { Capture(crusher, rb); }
public CompressedMatrix(TransformCrusher crusher) { this.crusher = crusher; }