public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { if (crosshair.sprite != null) { return(PreviewUtil.RenderStaticPreview(crosshair.sprite, width, height)); } return(Base64ToTexture(icon)); }
public HttpResponseMessage Preview([FromBody] Entities.OpenApi previewData) { Request request = Newtonsoft.Json.JsonConvert.DeserializeObject <Request>(previewData.Data); var response = new HttpResponseMessage(); response.Content = new StringContent(PreviewUtil.PreviewHTML(request)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html"); return(response); }
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { if (tile.m_DefaultSprite != null) { return(PreviewUtil.RenderStaticPreview(tile.m_DefaultSprite, width, height)); } return(base.RenderStaticPreview(assetPath, subAssets, width, height)); }
private void DrawSettings() { inventory.max = EditorGUILayout.Slider("Storage Space", inventory.max, 1, 1000); EditorGUILayout.Space(); GUILayout.Label("Content Filter:", EditorStyles.largeLabel); GUILayout.Label("Tags:"); // show tags GUILayout.BeginHorizontal(); for (int t = 0; t < inventory.canHoldTags.Count; t++) { GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.ExpandWidth(false)); if (inventory.canHoldTags[t].sprite != null) { GUILayout.Label(PreviewUtil.RenderStaticPreview(inventory.canHoldTags[t].sprite, 20, 20)); } GUILayout.Label(inventory.canHoldTags[t].name); if (GUILayout.Button("X", GUILayout.Width(20))) { inventory.canHoldTags.RemoveAt(t); EditorUtility.SetDirty(target); } GUILayout.EndHorizontal(); } ItemTag tt = (ItemTag)EditorGUILayout.ObjectField(null, typeof(ItemTag), false); if (tt != null) { if (!inventory.canHoldTags.Contains(tt)) { inventory.canHoldTags.Add(tt); EditorUtility.SetDirty(target); } } GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.Label("Item Types:"); // show types foreach (ItemType itm in inventory.CanHoldItems) { GUILayout.BeginHorizontal(EditorStyles.helpBox); if (itm.sprite != null) { GUILayout.Label(PreviewUtil.RenderStaticPreview(itm.sprite, 20, 20)); } GUILayout.Label(itm.display_name); GUILayout.EndHorizontal(); } if (GUILayout.Button("Search for Items with Tags")) { FindItemTypes(); } }
static void Main(string[] args) { var mlContext = new MLContext(); // Creates a loader which will help format the data var reader = mlContext.Data.CreateTextLoader( columns: new TextLoader.Column[] { new TextLoader.Column(CocoaPercent, DataKind.Single, 1), new TextLoader.Column("Label", DataKind.Single, 4) // Customer happiness is the label. The predicted features is called the Label. }, hasHeader: true // First line of the data file is a header and not data row ); IDataView trainingData = reader.Load(TrainDataPath); PreviewUtil.Show(trainingData); // Creates a pipeline - All operations like data operations, transformation, training are bundled as a pipeline var pipeline = mlContext.Transforms.Concatenate(outputColumnName: "Features", inputColumnNames: CocoaPercent) .Append(mlContext.Regression.Trainers.LbfgsPoissonRegression()); // Train the model var trainingModel = pipeline.Fit(trainingData); // Using the training for one-time prediction var predictionEngine = mlContext.Model.CreatePredictionEngine <ChocolateInput, ChocolateOutput>(trainingModel); // Get the prediction ChocolateOutput prediction = predictionEngine.Predict(new ChocolateInput() { CocoaPercent = 100 }); Console.WriteLine($"Predicted happiness: {prediction.CustomerHappiness}"); ChartGeneratorUtil.PlotRegressionChart(new PlotChartGeneratorModel() { Title = "Chocolate Consumer Happiness Prediction", LabelX = "Cocoa Percent", LabelY = "Customer Happiness", ImageName = "CocoaPercentToHappiness.png", PointsList = new List <PlotChartPointsList> { new PlotChartPointsList { Points = ChartGeneratorUtil.GetChartPointsFromFile(TrainDataPath, 1, 4).ToList() } }, MaxLimitY = ChartGeneratorUtil.GetMaxColumnValueFromFile(TrainDataPath, 4) + 10 }); Console.ReadKey(); }
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { if (itemType.sprite != null) { return(PreviewUtil.RenderStaticPreview(itemType.sprite, width, height)); } foreach (ItemTag t in itemType.tags) { if (t.sprite != null) { return(PreviewUtil.RenderStaticPreview(t.sprite, width, height)); } } return(Base64ToTexture(icon)); }
static void Main(string[] args) { var mlContext = new MLContext(); TextLoader reader = mlContext.Data.CreateTextLoader( columns: new TextLoader.Column[] { new TextLoader.Column("Weight", DataKind.Single, 0), new TextLoader.Column("CocoaPercent", DataKind.Single, 1), new TextLoader.Column("Cost", DataKind.Single, 2), new TextLoader.Column("Label", DataKind.Single, 3) // Label is customer happiness. The predicted feature is called the label }, hasHeader: true); IDataView trainingData = reader.Load(TrainingDataPath); PreviewUtil.Show(trainingData); var pipeline = mlContext.Transforms.Concatenate("Features", "Weight") .Append(mlContext.Regression.Trainers.LbfgsPoissonRegression()); var trainingModel = pipeline.Fit(trainingData); /* Get the graph data */ /* Build the graph */ /* Calculate metrics */ /* Get the predictions */ /* Show Graph 3D */ // TODO: Add Graph, update instructions Console.ReadKey(); }
private void DrawDefaultContents() { GUILayout.Label("Space: " + (inventory.FillPercentDefaults() * inventory.max).ToString() + " / " + inventory.max.ToString()); for (int i = 0; i < inventory.default_items.Count; i++) { if (inventory.default_items[i].itemType == null) { inventory.default_items.RemoveAt(i); if (i >= inventory.default_items.Count) { break; } } GUILayout.BeginHorizontal(EditorStyles.helpBox); if (inventory.default_items[i].itemType.sprite == null) { GUILayout.Label(new GUIContent(inventory.default_items[i].itemType.display_name, Base64ToTexture(item_icon)), GUILayout.Height(20), GUILayout.Width(150)); } else { GUILayout.Label(new GUIContent(inventory.default_items[i].itemType.display_name, PreviewUtil.RenderStaticPreview(inventory.default_items[i].itemType.sprite, 20, 20)), GUILayout.Width(150)); } GUILayout.Box(inventory.default_items[i].itemType.size.ToString()); inventory.default_items[i].itemType = (ItemType)EditorGUILayout.ObjectField(inventory.default_items[i].itemType, typeof(ItemType), false, GUILayout.Width(50)); inventory.default_items[i].count = EditorGUILayout.Slider(inventory.default_items[i].count, 1, inventory.MaxItemCountDefaults(inventory.default_items[i].itemType)); if (GUILayout.Button("X", GUILayout.Width(20))) { inventory.default_items.RemoveAt(i); } GUILayout.EndHorizontal(); } ItemType item = (ItemType)EditorGUILayout.ObjectField("Add New Item: ", null, typeof(ItemType), false); if (item != null) { bool isNew = true; foreach (Inventory.ItemSlot slot in inventory.default_items) { if (slot.itemType == item && slot.count + 1 < slot.itemType.max_stack && isNew) { isNew = false; slot.count++; break; } } if (isNew) { inventory.default_items.Add(new Inventory.ItemSlot(item)); EditorUtility.SetDirty(inventory); } } }
public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { return(PreviewUtil.RenderStaticPreview(tile.defaultSprite, width, height)); }
public override void OnInspectorGUI() { GUIStyle style = new GUIStyle(); style.normal.background = null; style.hover.background = null; style.active.background = null; //base.OnInspectorGUI(); manager.defaultZone = (Zone)EditorGUILayout.ObjectField("Default Zone", manager.defaultZone, typeof(Zone), false); manager.currentZone = (StringVariable)EditorGUILayout.ObjectField("Current Zone", manager.currentZone, typeof(StringVariable), false); manager.loadDistance = EditorGUILayout.IntSlider("Load Distance", manager.loadDistance, 1, 10); EditorGUILayout.Space(); if (GUILayout.Button("Find Zones")) { manager.zones.Clear(); string[] scenes = AssetDatabase.FindAssets("t:Scene"); string[] zones = AssetDatabase.FindAssets("t:Zone"); foreach (string z in zones) { Zone zz = (Zone)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(z), typeof(Zone)); if (!manager.zones.Contains(zz)) { manager.zones.Add(zz); } } foreach (string scene in scenes) { if (AssetDatabase.GUIDToAssetPath(scene).Contains("/Zones/")) { string[] path = AssetDatabase.GUIDToAssetPath(scene).Split('/'); string zone_path = ""; for (int i = 0; i < path.Length - 1; i++) { zone_path += path[i] + "/"; } string zone = path[path.Length - 1].Replace(".unity", ""); // now see if we can find the zones bool exists = false; foreach (Zone z in manager.zones) { if (z.name == zone) { exists = true; } } if (!exists) { Zone nZone = ScriptableObject.CreateInstance <Zone>(); nZone.zone = zone; nZone.name = zone; nZone.display_name = zone; AssetDatabase.CreateAsset(nZone, zone_path + zone + ".asset"); if (!manager.zones.Contains(nZone)) { manager.zones.Add(nZone); } } } } } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); GUILayout.Label("Icon", GUILayout.Width(65)); //GUILayout.Space(65); GUILayout.Space(20); GUILayout.Label("Zone", GUILayout.Width(128), GUILayout.Height(20)); GUILayout.Label("Description", GUILayout.ExpandWidth(true)); GUILayout.Label("Neighbors", GUILayout.Width(65)); GUILayout.EndHorizontal(); foreach (Zone zone in manager.zones) { GUILayout.BeginHorizontal(); zone.sprite = (Sprite)EditorGUILayout.ObjectField(zone.sprite, typeof(Sprite), false, GUILayout.Width(65)); if (zone.sprite != null) { GUILayout.Label(PreviewUtil.RenderStaticPreview(zone.sprite, 20, 20), GUILayout.Width(20)); } else { GUILayout.Label(Base64ToTexture(zone_icon), GUILayout.Width(20)); } //GUILayout.Label(zone.zone,GUILayout.Height(20),GUILayout.ExpandWidth(true)); if (zone.display_name == "") { zone.display_name = zone.name; } zone.display_name = EditorGUILayout.TextField(zone.display_name, GUILayout.Width(128)); zone.description = EditorGUILayout.TextField(zone.description); if (editing.ContainsKey(zone)) { if (GUILayout.Button("^", GUILayout.Width(40))) { editing.Remove(zone); } } else { if (zone.neighbor.Count == 0) { if (GUILayout.Button("Add", GUILayout.Width(40))) { editing.Add(zone, true); } } else { if (GUILayout.Button(zone.neighbor.Count.ToString(), GUILayout.Width(40))) { editing.Add(zone, true); } } } if (GUILayout.Button("X", GUILayout.Width(20))) { } GUILayout.EndHorizontal(); if (editing.ContainsKey(zone)) { GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Space(20); GUILayout.Label("Neighbors:", GUILayout.Width(128)); GUILayout.Label("Distance:"); GUILayout.EndHorizontal(); foreach (Zone zz in manager.zones) { if (zz != zone) { GUILayout.BeginHorizontal(); if (zone.neighbor.Contains(zz)) { if (GUILayout.Button(Base64ToTexture(linked), style, GUILayout.Width(20))) { zone.neighbor.Remove(zz); if (zz.neighbor.Contains(zone)) { zz.neighbor.Remove(zone); } } } else { if (GUILayout.Button(Base64ToTexture(unlinked), style, GUILayout.Width(20))) { zone.neighbor.Add(zz); if (!zz.neighbor.Contains(zone)) { zz.neighbor.Add(zone); } } } GUILayout.Label(zz.name, GUILayout.Width(128)); if (zone.neighbor.Count > 0) { int d = zz.Distance(zone.zone); if (d != 10) { GUILayout.Label(d.ToString()); } } GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); GUILayout.Space(20); GUILayout.EndHorizontal(); } } }
public override void OnInspectorGUI() { baseSetting = EditorGUILayout.Foldout(baseSetting, "Basic"); if (baseSetting) { EditorGUILayout.LabelField("Smoothing Settings"); mCam.movementLerpSpeed = EditorGUILayout.FloatField(" -Movement Lerp Speed", mCam.movementLerpSpeed); mCam.rotationLerpSpeed = EditorGUILayout.FloatField(" -Rotation Lerp Speed", mCam.rotationLerpSpeed); EditorGUILayout.Space(); EditorGUILayout.LabelField("Scroll Settings"); CamScrollAnimType tempType = mCam.scrollAnimationType; tempType = (CamScrollAnimType)EditorGUILayout.EnumPopup(" -Animation Type", tempType); if (tempType != mCam.scrollAnimationType && EditorUtility.DisplayDialog("Replacing Changes", "If you switch to another animation type, your settings in current mode will be replaced or modified.", "Continue", "Cancel")) { mCam.scrollAnimationType = tempType; } switch (mCam.scrollAnimationType) { case CamScrollAnimType.Simple: mCam.MinHight = EditorGUILayout.FloatField(" -Min High", mCam.MinHight); mCam.MaxHight = EditorGUILayout.FloatField(" -Max High", mCam.MaxHight); mCam.MinAngle = EditorGUILayout.FloatField(" -Min Angle", mCam.MinAngle); mCam.MaxAngle = EditorGUILayout.FloatField(" -Max Angle", mCam.MaxAngle); break; case CamScrollAnimType.Advanced: mCam.scrollXAngle = EditorGUILayout.CurveField(new GUIContent(" Scroll X Angle", "Scroll X Angle Animation"), mCam.scrollXAngle); mCam.scrollHigh = EditorGUILayout.CurveField(new GUIContent(" Scroll High", "Scroll High Animation"), mCam.scrollHigh); break; } mCam.ScrollValue = EditorGUILayout.Slider(" -Start Scroll Value", mCam.ScrollValue, 0f, 1f); EditorGUILayout.Space(); EditorGUILayout.LabelField("Casting Settings"); mCam.groundHighTest = EditorGUILayout.Toggle(" -Ground Check", mCam.groundHighTest); if (mCam.groundHighTest) { mCam.groundMask = PreviewUtil.LayerMaskField(" -Ground Mask", mCam.groundMask); } mCam.groundHighTestValMax = EditorGUILayout.FloatField(" -Ground Check Value", mCam.groundHighTestValMax); EditorGUILayout.Space(); } boundSetting = EditorGUILayout.Foldout(boundSetting, "Bound"); if (boundSetting) { mCam.bound.xMin = EditorGUILayout.FloatField(" -Min X", mCam.bound.xMin); mCam.bound.xMax = EditorGUILayout.FloatField(" -Max X", mCam.bound.xMax); mCam.bound.yMin = EditorGUILayout.FloatField(" -Min Z", mCam.bound.yMin); mCam.bound.yMax = EditorGUILayout.FloatField(" -Max Z", mCam.bound.yMax); if (GUILayout.Button("Use Suggested Values") && EditorUtility.DisplayDialog("替换你当前的设置", "自动扫描,来设置范围大小.", "Confirm", "Cancel")) { Bounds[] discoveredBounds; MeshRenderer[] renderers = Resources.FindObjectsOfTypeAll <MeshRenderer>(); discoveredBounds = new Bounds[renderers.Length]; EditorUtility.DisplayProgressBar("Calculating...", "Finding objects...", 0); for (int i = 0; i < discoveredBounds.Length; i++) { discoveredBounds[i] = renderers[i].bounds; } EditorUtility.DisplayProgressBar("Calculating...", "Calculating bounds along X...", 0.25f); float endValues = Mathf.Infinity; for (int i = 0; i < discoveredBounds.Length; i++) { if (endValues > discoveredBounds[i].min.x) { endValues = discoveredBounds[i].min.x; } } mCam.bound.xMin = endValues; EditorUtility.DisplayProgressBar("Calculating...", "Calculating bounds along X...", 0.5f); endValues = Mathf.NegativeInfinity; for (int i = 0; i < discoveredBounds.Length; i++) { if (endValues < discoveredBounds[i].max.x) { endValues = discoveredBounds[i].max.x; } } mCam.bound.xMax = endValues; EditorUtility.DisplayProgressBar("Calculating...", "Calculating bounds along Z...", 0.75f); endValues = Mathf.Infinity; for (int i = 0; i < discoveredBounds.Length; i++) { if (endValues > discoveredBounds[i].min.z) { endValues = discoveredBounds[i].min.z; } } mCam.bound.yMin = endValues; EditorUtility.DisplayProgressBar("Calculating...", "Calculating bounds along Z...", 0.99f); endValues = Mathf.NegativeInfinity; for (int i = 0; i < discoveredBounds.Length; i++) { if (endValues < discoveredBounds[i].max.z) { endValues = discoveredBounds[i].max.z; } } mCam.bound.yMax = endValues; EditorUtility.ClearProgressBar(); } EditorGUILayout.HelpBox("The white rectangle in scene view will help you configure scene bounds.", MessageType.Info); EditorGUILayout.Space(); } followSetting = EditorGUILayout.Foldout(followSetting, "Follow"); if (followSetting) { mCam.allowFollow = EditorGUILayout.Toggle(" -Allow Follow", mCam.allowFollow); if (mCam.allowFollow) { mCam.unlockWhenMove = EditorGUILayout.Toggle(" -Unlock When Move", mCam.unlockWhenMove); } else { EditorGUILayout.HelpBox("Enable Follow to let your camera focus something on center of screen or go to a fixed point.", MessageType.Info); } EditorGUILayout.Space(); } controlSetting = EditorGUILayout.Foldout(controlSetting, "Control"); if (controlSetting) { //Screen Edge mCam.mouseScreenEdgeMoveControl = EditorGUILayout.Toggle(" Mouse Screen Edge Movement", mCam.mouseScreenEdgeMoveControl); if (mCam.mouseScreenEdgeMoveControl) { mCam.desktopMoveSpeed = EditorGUILayout.FloatField(" -Move Speed", mCam.desktopMoveSpeed); mCam.deskScreenEdgeWidth = EditorGUILayout.FloatField(" -Edge Width", mCam.deskScreenEdgeWidth); mCam.desktopDisSEMWhenDrag = EditorGUILayout.Toggle(" -Dis when drag", mCam.desktopDisSEMWhenDrag); } EditorGUILayout.Space(); //Drag mCam.mouseDragControl = EditorGUILayout.Toggle(" Mouse Drag Control", mCam.mouseDragControl); if (mCam.mouseDragControl) { mCam.mouseDragButton = System.Convert.ToInt32(EditorGUILayout.EnumPopup(" -Move Button", (MouseButton)mCam.mouseDragButton)); mCam.desktopMoveDragSpeed = EditorGUILayout.FloatField(" -Move Speed", mCam.desktopMoveDragSpeed); if (mCam.mouseDragButton == mCam.mouseRotateButton) { EditorGUILayout.HelpBox("Control button overlapping.", MessageType.Warning); } } EditorGUILayout.Space(); //Rotation mCam.mouseRotateControl = EditorGUILayout.Toggle(" Mouse Rotate Control", mCam.mouseRotateControl); if (mCam.mouseRotateControl) { mCam.mouseRotateButton = System.Convert.ToInt32(EditorGUILayout.EnumPopup(" -Rotate Button", (MouseButton)mCam.mouseRotateButton)); mCam.desktopRotateSpeed = EditorGUILayout.FloatField(" -Rotate Speed", mCam.desktopRotateSpeed); if (mCam.mouseDragButton == mCam.mouseRotateButton) { EditorGUILayout.HelpBox("Control button overlapping.", MessageType.Warning); } } EditorGUILayout.Space(); //Scroll mCam.mouseScrollControl = EditorGUILayout.Toggle(" Mouse Scroll Control", mCam.mouseScrollControl); if (mCam.mouseScrollControl) { mCam.desktopScrollSpeed = EditorGUILayout.FloatField(" -Scroll Speed", mCam.desktopScrollSpeed); } EditorGUILayout.Space(); //Touch mCam.touchScreenEdgeMoveControl = EditorGUILayout.Toggle(" Touch Screen Edge Movement", mCam.touchScreenEdgeMoveControl); if (mCam.touchScreenEdgeMoveControl) { mCam.touchMoveSpeed = EditorGUILayout.FloatField(" -Move Speed", mCam.touchMoveSpeed); mCam.touchScreenEdgeWidth = EditorGUILayout.FloatField(" -Edge Width", mCam.touchScreenEdgeWidth); } EditorGUILayout.Space(); mCam.touchDragControl = EditorGUILayout.Toggle(" Touch Drag Control", mCam.touchDragControl); if (mCam.touchDragControl) { mCam.touchMoveDragSpeed = EditorGUILayout.FloatField(" -Move Speed", mCam.touchMoveDragSpeed); } EditorGUILayout.Space(); mCam.touchRotateControl = EditorGUILayout.Toggle(" Touch Rotate Control", mCam.touchRotateControl); if (mCam.touchRotateControl) { mCam.touchRotateSpeed = EditorGUILayout.FloatField(" -Rotate Speed", mCam.touchRotateSpeed); } EditorGUILayout.Space(); mCam.touchScrollControl = EditorGUILayout.Toggle(" Touch Scroll Control", mCam.touchScrollControl); if (mCam.touchScrollControl) { mCam.touchScrollSpeed = EditorGUILayout.FloatField(" -Scroll Speed", mCam.touchScrollSpeed); } EditorGUILayout.Space(); } if (GUILayout.Button("Save")) { EditorUtility.SetDirty(mCam); AssetDatabase.SaveAssets(); EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); EditorSceneManager.SaveOpenScenes(); } }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Name", GUILayout.Width(label_width)); playerItem.display_name = EditorGUILayout.TextField(playerItem.display_name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Sprite", GUILayout.Width(label_width)); playerItem.sprite = (Sprite)EditorGUILayout.ObjectField(playerItem.sprite, typeof(Sprite), false); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Prefab", GUILayout.Width(label_width)); playerItem.prefab = (GameObject)EditorGUILayout.ObjectField(playerItem.prefab, typeof(GameObject), false); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Size", GUILayout.Width(label_width)); playerItem.width = EditorGUILayout.IntField(playerItem.width); GUILayout.Label("x"); playerItem.height = EditorGUILayout.IntField(playerItem.height); GUILayout.Label("Max Stacks", GUILayout.Width(80)); playerItem.max_stack = EditorGUILayout.FloatField(playerItem.max_stack); GUILayout.EndHorizontal(); playerItem.size = playerItem.width * playerItem.height; GUILayout.Label("Description:"); playerItem.description = EditorGUILayout.TextArea(playerItem.description); // show tags GUILayout.BeginHorizontal(); for (int t = 0; t < playerItem.tags.Count; t++) { GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.ExpandWidth(false)); if (playerItem.tags[t].sprite != null) { GUILayout.Label(PreviewUtil.RenderStaticPreview(playerItem.tags[t].sprite, 20, 20)); } GUILayout.Label(playerItem.tags[t].name); if (GUILayout.Button("X", GUILayout.Width(20))) { playerItem.tags.RemoveAt(t); } GUILayout.EndHorizontal(); } ItemTag tt = (ItemTag)EditorGUILayout.ObjectField(null, typeof(ItemTag), false); if (tt != null) { if (!playerItem.tags.Contains(tt)) { EditorUtility.SetDirty(target); playerItem.tags.Add(tt); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); if (playerItem.width > 3) { playerItem.width = 3; } if (playerItem.width < 1) { playerItem.width = 1; } if (playerItem.height > 3) { playerItem.height = 3; } if (playerItem.height < 1) { playerItem.height = 1; } playerItem.sprite = (Sprite)EditorGUILayout.ObjectField("", playerItem.sprite, typeof(Sprite), false, GUILayout.Width(128), GUILayout.Height(128)); GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.Label("Nouns and Verbs:"); GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginHorizontal(); GUILayout.Label("You"); playerItem.verb_past = EditorGUILayout.TextField(playerItem.verb_past); playerItem.indefinite_article = (ItemType.indefiniateArticle)EditorGUILayout.EnumPopup(playerItem.indefinite_article, GUILayout.Width(50)); playerItem.display_name = EditorGUILayout.TextField(playerItem.display_name); GUILayout.Label("today."); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); //GUILayout.Label("You"); playerItem.verb_present = EditorGUILayout.TextField(playerItem.verb_present); GUILayout.Label("some"); playerItem.plural_name = EditorGUILayout.TextField(playerItem.plural_name); //GUILayout.Label("now."); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("You will"); playerItem.verb_future = EditorGUILayout.TextField(playerItem.verb_future); GUILayout.Label("more"); playerItem.plural_name = EditorGUILayout.TextField(playerItem.plural_name); GUILayout.Label("tomorrow."); GUILayout.EndHorizontal(); GUILayout.EndVertical(); EditorGUILayout.Space(); GUILayout.Label("Use Affects:"); for (int i = 0; i < playerItem.affect.Count; i++) { GUILayout.BeginHorizontal(EditorStyles.helpBox); GUILayout.Label(playerItem.affect[i].display_name); GUILayout.Label(playerItem.affect[i].discription); playerItem.affect[i] = (ItemAffect)EditorGUILayout.ObjectField(playerItem.affect[i], typeof(ItemAffect), false, GUILayout.Width(80)); if (GUILayout.Button("X", GUILayout.Width(20))) { playerItem.affect.Remove(playerItem.affect[i]); i--; } GUILayout.EndHorizontal(); } EditorGUILayout.Space(); GUILayout.BeginHorizontal(); EditorGUILayout.Space(); GUILayout.Label("Add Use Affect: "); ItemAffect itemAffect = (ItemAffect)EditorGUILayout.ObjectField(null, typeof(ItemAffect), false); GUILayout.EndHorizontal(); if (itemAffect != null) { playerItem.affect.Add(itemAffect); } playerItem.name = playerItem.display_name; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { ghdoc = this.OnPingDocument(); ghdoc.ContextChanged += new GH_Document.ContextChangedEventHandler(CheckDisplay); Model input = null; DA.GetData(0, ref input); if (input.Mesh == null) { return; } Model model = input.Clone() as Model; Grasshopper.Kernel.Types.GH_ObjectWrapper type0D = null; Grasshopper.Kernel.Types.GH_ObjectWrapper type1D = null; Grasshopper.Kernel.Types.GH_ObjectWrapper type2D = null; DA.GetData(1, ref type0D); DA.GetData(2, ref type1D); DA.GetData(3, ref type2D); type0D.Value.CheckResultDimension(0); type1D.Value.CheckResultDimension(1); type2D.Value.CheckResultDimension(2); string nodeResultType = type0D.ToString(); string barResType = type1D.ToString(); string panelResType = type2D.ToString(); bool showVals, showNds, showEdgs, deformed, showLCS, showLoads, showSupports, showCNs, showNNs, showENs, showLVals; showVals = showNds = showEdgs = deformed = showLCS = showLoads = showSupports = showCNs = showNNs = showENs = showLVals = false; double TFactor, GFactor, Dfactor; TFactor = GFactor = Dfactor = 0; DA.GetData(4, ref showVals); DA.GetData(5, ref showNds); DA.GetData(6, ref showEdgs); DA.GetData(7, ref deformed); DA.GetData(8, ref showLCS); DA.GetData(9, ref showLoads); DA.GetData(10, ref showSupports); DA.GetData(11, ref showCNs); DA.GetData(12, ref showNNs); DA.GetData(13, ref showENs); DA.GetData(14, ref showLVals); DA.GetData(15, ref TFactor); DA.GetData(16, ref GFactor); DA.GetData(17, ref Dfactor); List <int> panelIds = new List <int>(); List <int> barIds = new List <int>(); DA.GetDataList(18, barIds); DA.GetDataList(19, panelIds); double[] sizeFactors = model.sizeFactors(); double EFactor = sizeFactors[0]; double FFactor = sizeFactors[1]; if (deformed) { model.Mesh.Deform(Dfactor); } m_display = new Rhino.Display.CustomDisplay(!this.Hidden); Grasshopper.GUI.Gradient.GH_Gradient gradient = PreviewUtil.CreateStandardGradient(); HashSet <int> nodeIds = new HashSet <int>(); HashSet <int> barNodeIds; HashSet <int> panelNodeIds; m_display.AddBarPreview(model, barIds, out barNodeIds, GFactor, EFactor, TFactor, showCNs, showENs, showLCS, false, barResType, showVals); m_display.AddPanelPreview(model, panelIds, out panelNodeIds, GFactor, EFactor, TFactor, FFactor, showCNs, showENs, showLCS, showLoads, showLVals, showEdgs, false, gradient, panelResType, showVals); nodeIds.UnionWith(panelNodeIds); nodeIds.UnionWith(barNodeIds); m_display.AddNodePreview(model, nodeIds, GFactor, EFactor, TFactor, FFactor, showNds, showNNs, showLoads, showLVals, gradient, nodeResultType, showVals); if (showSupports) { m_display.AddSupportPreview(model, nodeIds, EFactor, GFactor); } }
public override void OnInspectorGUI() { //base.OnInspectorGUI(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.Label("Name", GUILayout.Width(label_width)); itemType.display_name = EditorGUILayout.TextField(itemType.display_name); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Sprite", GUILayout.Width(label_width)); itemType.sprite = (Sprite)EditorGUILayout.ObjectField(itemType.sprite, typeof(Sprite), false); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Size", GUILayout.Width(label_width)); itemType.size = EditorGUILayout.FloatField(itemType.size); GUILayout.Label("Max Stacks", GUILayout.Width(80)); itemType.max_stack = EditorGUILayout.FloatField(itemType.max_stack); GUILayout.EndHorizontal(); GUILayout.Label("Description:"); itemType.description = GUILayout.TextArea(itemType.description); if (itemType.tags == null) { itemType.tags = new List <ItemTag>(); } // show tags GUILayout.BeginHorizontal(); for (int t = 0; t < itemType.tags.Count; t++) { GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.ExpandWidth(false)); if (itemType.tags[t].sprite != null) { GUILayout.Label(PreviewUtil.RenderStaticPreview(itemType.tags[t].sprite, 20, 20)); } GUILayout.Label(itemType.tags[t].name); if (GUILayout.Button("X", GUILayout.Width(20))) { itemType.tags.RemoveAt(t); EditorUtility.SetDirty(target); } GUILayout.EndHorizontal(); } ItemTag tt = (ItemTag)EditorGUILayout.ObjectField(null, typeof(ItemTag), false); if (tt != null) { if (!itemType.tags.Contains(tt)) { itemType.tags.Add(tt); EditorUtility.SetDirty(target); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); itemType.sprite = (Sprite)EditorGUILayout.ObjectField("", itemType.sprite, typeof(Sprite), false, GUILayout.Width(100), GUILayout.Height(100)); GUILayout.EndHorizontal(); EditorGUILayout.Space(); GUILayout.Label("Sentences:"); GUILayout.BeginHorizontal(); GUILayout.Label("There is"); itemType.indefinite_article = (ItemType.indefiniateArticle)EditorGUILayout.EnumPopup(itemType.indefinite_article, GUILayout.Width(50)); itemType.display_name = EditorGUILayout.TextField(itemType.display_name); GUILayout.Label("on the table."); GUILayout.EndHorizontal(); if (itemType.indefinite_article != ItemType.indefiniateArticle.None) { GUILayout.BeginHorizontal(); GUILayout.Label("There are two"); itemType.plural_name = EditorGUILayout.TextField(itemType.plural_name); GUILayout.Label("on the table."); GUILayout.EndHorizontal(); } else { GUILayout.BeginHorizontal(); GUILayout.Label("There are two units of"); itemType.plural_name = EditorGUILayout.TextField(itemType.plural_name); GUILayout.Label("on the table."); GUILayout.EndHorizontal(); } }