public void PinCustom(TerrainTile tile) { if (!customTiles.Contains(tile)) { ArrayTools.Add(ref customTiles, tile); } }
public Line AddLine(Vector3 start, Vector3 end) { Line line = new Line(start, end); ArrayTools.Add(ref lines, line); return(line); }
public T[] CheckAppendLayers <T> (T[] layers) where T : class /// If there is no such prototype in layers - appending layers with newly created prototype /// Returns layers themselves if no need to add { int currInstNum = 0; Object thisObj = Object; bool foundInLayers = false; for (int i = 0; i < layers.Length; i++) { Object layerObj = GetLayerObject(layers.GetValue(i)); if (layerObj == null) { continue; } if (layerObj == thisObj) { if (currInstNum == instanceNum) { foundInLayers = true; break; } currInstNum++; } } if (!foundInLayers) { ArrayTools.Add(ref layers, NewLayer <T>(this)); } return(layers); }
public void SetTexture(string name, Texture2D texture) { if (terrain == null) { terrain = GetComponent <Terrain>(); } if (matProps == null) { matProps = new MaterialPropertyBlock(); } matProps.SetTexture(name, texture); int index = names.Find(name); if (index < 0) { ArrayTools.Add(ref names, name); ArrayTools.Add(ref textures, texture); } else { textures[index] = texture; } }
public static Vector Add(Vector u, Vector v) { Vector Vector1 = new Vector(); Vector1.Values = ArrayTools.Add(u.Values, v.Values); return(Vector1); }
public static T LoadAsset <T> (string label = "Load Unity Asset", string[] filters = null) where T : UnityEngine.Object { #if UNITY_EDITOR if (filters == null && typeof(T).IsSubclassOf(typeof(Texture))) { filters = new string[] { "Textures", "PSD,TIFF,TIF,JPG,TGA,PNG,GIF,BMP,IFF,PICT" } } ; if (filters == null && typeof(T) == typeof(Transform)) { filters = new string[] { "Meshes", "FBX,DAE,3DS,DXF,OBJ,SKP" } } ; ArrayTools.Add(ref filters, "All files"); ArrayTools.Add(ref filters, "*"); string path = UnityEditor.EditorUtility.OpenFilePanelWithFilters(label, "Assets", filters); if (path != null && path.Length != 0) { path = path.Replace(Application.dataPath, "Assets"); T asset = (T)UnityEditor.AssetDatabase.LoadAssetAtPath(path, typeof(T)); return(asset); } #endif return(null); } } }
/// <summary> /// Return a vector that is an addition of the two vectors: w = u+v /// </summary> /// <param name="u"></param> /// <param name="v"></param> /// <returns></returns> public static Vector Add(double[] u, double[] v) { Vector Vector1 = new Vector(); Vector1.Values = ArrayTools.Add(u, v); return(Vector1); }
public static Vector operator +(Vector Vector1, double[] Vector2) { Vector Vector3 = new Vector(); Vector3.Values = ArrayTools.Add(Vector1.Values, Vector2); Vector3.Rows = Vector3.Values.Length; return(Vector3); }
/// <summary> /// Return a vecto which is this vector plus the given vector: z_i = x_i+y_i /// </summary> /// <param name="Vector2"></param> /// <returns></returns> public Vector Plus(double[] Vector2) { Vector Vector3 = new Vector(); Vector3.Values = ArrayTools.Add(this.Values, Vector2); Vector3.Rows = Vector3.Values.Length; return(Vector3); }
public void Add(Group grp) { if (ArrayTools.Contains(groups, grp)) { throw new Exception("Could not add group " + grp + " since it is already in graph"); } ArrayTools.Add(ref groups, grp); //cachedGuidLut = null; }
public void Add(Generator node) { if (ArrayTools.Contains(generators, node)) { throw new Exception("Could not add generator " + node + " since it is already in graph"); } ArrayTools.Add(ref generators, node); //cachedGuidLut = null; }
public static void DestroyAllChilds(this UnityEngine.Transform root) { var childs = new UnityEngine.GameObject[0]; foreach (UnityEngine.Transform child in root) { ArrayTools.Add(ref childs, child.gameObject); } childs.DoForAll(UnityEngine.Object.Destroy); ArrayTools.Clear(ref childs); }
public TweeningParameter[] this[TweeningParameter.Type filter] { get { var result = new TweeningParameter[0]; foreach (var parameter in Parameters) { if (parameter.ParameterType.Equals(filter)) { ArrayTools.Add(ref result, parameter); } } return(result); } }
public static T ThrowDice <T>(T[] weights) where T : IWeight { var sum = 0f; foreach (T weight in weights) { sum += weight.Value; } var selection = new T[0]; foreach (T weight in weights) { var count = ( int )(weight.Value * 100f / sum + 0.5f); ArrayTools.DoTimes(() => count, index => { ArrayTools.Add(ref selection, weight); }); } return(selection[Random.Range(0, selection.Length)]); }
public bool AddHost(string url) { if (url.IsNull() || (url = url.Trim()).IsNullOrEmpty()) { return(false); } if (!Validation(ConnectionManager.WSS + url.Split(new[] { ConnectionManager.SEPARATOR }, StringSplitOptions.None).Last())) { return(false); } var currentUrls = Urls; if (currentUrls.Contains(url)) { return(false); } ArrayTools.Add(ref currentUrls, url); Urls = currentUrls; return(true); }
public void Expose(IExposedGuid obj, FieldInfo field, string name = null) { if (entries == null) { entries = new Entry[0]; } if (IsExposed(obj, field)) { Unexpose(obj, field); } Entry entry = new Entry() { guid = obj.Guid, type = field.FieldType, fieldName = field.Name, guiName = name != null ? name : field.Name.Nicify() }; ArrayTools.Add(ref entries, entry); }
/*UI ui = new UI(); * SplineObject so; * * public void OnSceneGUI () * { * if (so == null) so = (SplineObject)target; * ui.DrawInspector(() => DrawSpline(so.splineSys)); * }*/ public static void DrawSpline(SplineObject obj) { using (Cell.LineStd) using (new Draw.FoldoutGroup(ref guiDisplay, "Display", isLeft: true)) if (guiDisplay) { using (Cell.LineStd) Draw.ToggleLeft(ref obj.drawNodes, "Draw Nodes"); using (Cell.LineStd) Draw.ToggleLeft(ref obj.drawLines, "Draw Segments"); using (Cell.LineStd) Draw.ToggleLeft(ref obj.drawBeizer, "Draw Beizer"); if (Cell.current.valChanged) { SceneView.lastActiveSceneView?.Repaint(); } } Cell.EmptyLinePx(4); using (Cell.LineStd) using (new Draw.FoldoutGroup(ref guiLines, "Splines", isLeft: true)) if (guiLines) { using (Cell.LineStd) Draw.DualLabel("Lines Count", obj.splines.Length.ToString()); if (SplineEditor.selectedNodes.Count == 1) { (int l, int n) = SplineEditor.selectedNodes.Any(); Spline spline = obj.splines[l]; //using (Cell.LineStd) Draw.DualLabel("Length", spline.length.ToString()); using (Cell.LineStd) Draw.DualLabel("Node Counts", spline.nodes.Length.ToString()); //using (Cell.LineStd) Draw.Toggle(ref spline.looped, "Looped"); using (Cell.LineStd) if (Draw.Button("Remove")) { ArrayTools.RemoveAt(ref obj.splines, l); SplineEditor.selectedNodes.Clear(); SplineEditor.dispSelectedNodes.Clear(); } } using (Cell.LineStd) if (Draw.Button("Add")) { Spline newSpline = new Spline( SceneView.lastActiveSceneView.pivot - new Vector3(SceneView.lastActiveSceneView.cameraDistance / 10, 0, 0), SceneView.lastActiveSceneView.pivot + new Vector3(SceneView.lastActiveSceneView.cameraDistance / 10, 0, 0)); newSpline.nodes[0].y = 0; newSpline.nodes[1].y = 0; ArrayTools.Add(ref obj.splines, newSpline); } } Cell.EmptyLinePx(4); using (Cell.LineStd) using (new Draw.FoldoutGroup(ref guiKnobs, "Nodes", isLeft: true)) if (guiKnobs) { using (Cell.LineStd) Draw.DualLabel("Selected", SplineEditor.selectedNodes.Count.ToString()); if (SplineEditor.selectedNodes.Count == 1) { Cell.EmptyLinePx(4); (int l, int n) = SplineEditor.selectedNodes.Any(); using (Cell.LinePx(0)) DrawNode(obj.splines, l, n); } } /*Cell.EmptyLinePx(4); * using (Cell.LineStd) * if (Draw.Button("Update")) * { * sys.Update(); * SceneView.lastActiveSceneView?.Repaint(); * }*/ }
public void AddLine(Line line) { ArrayTools.Add(ref lines, line); }
public void AddSegment(Segment segment) { ArrayTools.Add(ref segments, segment); }