public static GlassType CreateGlassTypeObject(string name, GameObject _parent) { GlassType glassType = null; foreach (GlassType gt in _parent.GetComponents <GlassType>()) { if (gt.presetName == name) { glassType = gt; } } if (glassType == null) { glassType = _parent.AddComponent <GlassType>(); } /* * foreach (GlassType gt in GameObject.FindObjectsOfType<GlassType>()) * { * if (gt.presetName == name) * { * glassType = gt; * } * } * if (glassType == null) * { * GameObject go = new GameObject(name); * go.transform.parent = _parent.transform; * glassType = go.AddComponent<GlassType>(); * } */ return(glassType); }
public void RemoveNullypes() { while (glassTypes.Contains(null)) { glassTypes.Remove(null); } for (int i = glassTypes.Count - 1; i >= 0; i--) { GlassType glassType = glassTypes[i]; if (glassType.isCopy) { if (glassType.original == null) { RemoveCopy(glassType); } else { if (!glassType.original.IsCopy(glassType)) { RemoveCopy(glassType); } } } } foreach (GlassType glassType in glassTypes) { glassType.RemoveNullObjects(); } }
public void AddCopy(GlassType copy, GlassType original) { glassTypes.Insert(glassTypes.IndexOf(original) + 1, copy); copy.previousIndex = glassTypes.IndexOf(copy); copy.previousItemAbove = original; copy.previousItemBelow = GetGlassTypeAfter(copy); }
public static GlassType Create(GlassType original, GlassRenderOrderManager manager) { GlassType glassType = CreateGlassTypeObject(CopyName(original), manager.gameObject); glassType.hideFlags = glassTypeHideFlags; glassType.Setup(original); return(glassType); }
public static GlassType Create(Glass instance, GlassRenderOrderManager manager) { GlassType glassType = CreateGlassTypeObject(instance.presetName, manager.gameObject); glassType.hideFlags = glassTypeHideFlags; glassType.Setup(instance); return(glassType); }
public int CopyNumber(GlassType glassType) { if (!IsCopy(glassType)) { return(-1); } return(copies.IndexOf(glassType) + 2); }
void FinishedMoveChecks() { for (int i = 0; i < glassTypes.Count; i++) { GlassType glassType = glassTypes[i]; glassType.FinishedMoveChecks(i, GetGlassType(i - 1), GetGlassType(i + 1)); } }
public bool MatchingRenderOrder(GlassType other) { if (other == null) { return(false); } return(renderOrder == other.renderOrder); }
public void DepthQualityChanged_Other(Glass glass) { GlassType glassType = FindType(glass); if (glassType != null) { glassType.DepthQualityChanged_Other(glass); } }
/* * public GlassType(Material _nonGlassMaterial) * { * Setup(_nonGlassMaterial); * } * * public GlassType(Glass instance) * { * Setup(instance); * } * * public GlassType(GlassType glassType) * { * Setup(glassType); * } */ public void Setup(GlassType glassType) { presetName = glassType.presetName; material_front = glassType.material_front; material_back = glassType.material_back; manager = glassType.manager; renderOrder = glassType.renderOrder; hideFlags = glassTypeHideFlags; }
public static GlassType Create(Material _nonGlassMaterial, GlassRenderOrderManager manager) { GlassType glassType = CreateGlassTypeObject(_nonGlassMaterial.name, manager.gameObject); glassType.hideFlags = glassTypeHideFlags; glassType.Setup(_nonGlassMaterial); glassType.isGlass = false; return(glassType); }
private void CopyMaterials(GlassType original) { material_back = new Material(Shader.Find(original.material_back.shader.name)); material_back.CopyPropertiesFromMaterial(original.material_back); material_back.renderQueue = material_back.renderQueue; // material_front = new Material(Shader.Find(original.material_front.shader.name)); material_front.CopyPropertiesFromMaterial(original.material_front); material_front.renderQueue = material_front.renderQueue; }
public List <GlassType> GetGlassTypesAfter(GlassType movedType) { if (movedType != null) { return(GetGlassTypesAfter(movedType.previousIndex)); } else { return(new List <GlassType>()); } }
bool SwapRenderOrder(int makeEarliest, int makeLatest) { GlassType earliestType = glassTypes[makeEarliest]; GlassType latestType = glassTypes[makeLatest]; int renderOrder1 = earliestType.renderOrder; int renderOrder2 = latestType.renderOrder; earliestType.renderOrder = Mathf.Min(renderOrder1, renderOrder2); latestType.renderOrder = Mathf.Max(renderOrder1, renderOrder2); return(earliestType.renderOrder != latestType.renderOrder); }
public bool IsCopyOrOriginal(GlassType glassType) { if (IsOriginal(glassType)) { return(true); } else { return(IsCopy(glassType)); } }
public bool IsCopy(GlassType potentialCopy) { if (potentialCopy == this) { return(false); } if (potentialCopy == null) { return(false); } return(copies.Contains(potentialCopy)); }
public static void DestroyGlassType(GlassType glassType) { if (glassType == null) { return; } #if UNITY_EDITOR DestroyImmediate(glassType); #else Destroy(glassType); #endif }
public bool IsOriginal(GlassType potentialOriginal) { if (potentialOriginal == null) { return(false); } if (original == null) { return(false); } return(original == potentialOriginal); }
public void AddGlassType(Material nonGlassMaterial) { GlassType glassType = GlassType.Create(nonGlassMaterial, this); //new GlassType(nonGlassMaterial); glassType.previousIndex = glassTypes.Count; if (glassTypes.Count > 0) { glassType.previousItemAbove = glassTypes[glassTypes.Count - 1]; glassTypes[glassTypes.Count - 1].previousItemBelow = glassType; } glassTypes.Add(glassType); }
bool MakeSureRenderOrderAfter(ref GlassType typeToMove, GlassType pivot) { if (pivot == null) { return(false); } if (typeToMove == null) { return(false); } return(typeToMove.MakeSureRendeOrderAfter(pivot.renderOrder)); }
public void SetRenderOrderFromOrder(int index, GlassType itemAbove, GlassType itemBelow) { bool canChangeOrder = true; bool valueAfterAbove = false; bool valueBeforeBelow = false; // if (previousIndex == index) { canChangeOrder = false; } // if (itemAbove == previousItemAbove && itemBelow == previousItemBelow) { canChangeOrder = false; } // else if (itemAbove != previousItemAbove) { canChangeOrder = false; valueAfterAbove = true; } // else if (itemBelow != previousItemBelow) { canChangeOrder = false; valueBeforeBelow = true; } // previousIndex = index; previousItemAbove = itemAbove; previousItemBelow = itemBelow; // if (canChangeOrder) { SetRenderOrder(Glass.default_customRenderOrder + index); } else if (valueAfterAbove) { if (previousItemAbove != null) { SetRenderOrder(previousItemAbove.renderOrder + 1); } } else if (valueBeforeBelow) { if (previousItemBelow != null) { SetRenderOrder(previousItemBelow.renderOrder - 1); } } }
public void AddGlassType(Glass glass) { GlassType glassType = GlassType.Create(glass, this);//new GlassType(glass); glassType.previousIndex = glassTypes.Count; if (glassTypes.Count > 0) { glassType.previousItemAbove = glassTypes[glassTypes.Count - 1]; glassTypes[glassTypes.Count - 1].previousItemBelow = glassType; } glassType.AddInstance(glass); glassTypes.Add(glassType); }
public GlassType GetGlassTypeBefore(GlassType glassType) { int index = glassTypes.IndexOf(glassType); index--; if (index >= 0) { return(glassTypes[index]); } else { return(null); } }
public static GlassType CreateCopy(GlassType original, GlassRenderOrderManager _manager) { GlassType copy = CreateGlassTypeObject(CopyName(original), _manager.gameObject); copy.Setup(original); copy.isCopy = true; copy.original = original; original.copies.Add(copy); copy.CopyMaterials(original); return(copy); }
public GlassType GetGlassTypeAfter(GlassType glassType) { int index = glassTypes.IndexOf(glassType); index++; if (index < glassTypes.Count) { return(glassTypes[index]); } else { return(null); } }
public void UpdateGlassTypes() { for (int i = 0; i < glassTypes.Count; i++) { GlassType glassType = glassTypes[i]; glassType.UpdateGlassValues(); if (glassType.previousIndex == -1) { glassType.previousIndex = i; glassType.previousItemAbove = GetGlassTypeBefore(glassType); glassType.previousItemBelow = GetGlassTypeAfter(glassType); } } }
public void RemoveCopy(GlassType copy) { if (!copy.isCopy) { return; } GlassType original = copy.original; if (original != null) { original.RemoveCopy(copy); } glassTypes.Remove(copy); DestroyGlassType(copy); }
void CalculateMoveData(ref GlassType movedType, ref int moveDirection) { int moveAmount = 0; for (int i = 0; i < glassTypes.Count; i++) { GlassType glassType = glassTypes[i]; moveAmount = glassType.MoveAmount(i, GetGlassType(i - 1), GetGlassType(i + 1)); if (moveAmount != 0) { movedType = glassType; moveDirection = moveAmount; } } }
/// <summary> /// MoveAmount based on new index, item above (less than), and item below (more than) /// </summary> /// <param name="i"></param> /// <param name="glassTypeAbove"></param> /// <param name="glassTypeBelow"></param> /// <returns></returns> public int MoveAmount(int index, GlassType itemAbove, GlassType itemBelow) { bool moved = true; int direction = 0; if (index == previousIndex) { moved = false; } else if (itemAbove == previousItemAbove || itemBelow == previousItemBelow) { moved = false; } if (moved) { direction = previousIndex - index; } return(direction); }
public void RemoveEmptyTypes() { for (int i = glassTypes.Count - 1; i >= 0; i--) { GlassType glassType = glassTypes[i]; if (!glassType.isCopy && glassType.isGlass) { if (glassType.instances.Count == 0) { glassTypes.Remove(glassType); DestroyGlassType(glassType); } } else if (glassType.isGlass) { if (glassType.original == null) { glassTypes.Remove(glassType); DestroyGlassType(glassType); } } } }