protected override void OnReset() { Type type = this.GetType(); LayoutViewDisplayAttributeAttribute settings = AttributeUtility.FindAttribute <LayoutViewDisplayAttributeAttribute>(type); if (settings == null) { throw new MissingReferenceException("Missing [LayoutSceneViewDisplay] attribute declaration for the class '" + type.Name + "'"); } SceneView sceneView = SceneView.currentDrawingSceneView; if (sceneView == null) { StratusDebug.Log("No scene view?"); return; } // Read and set the properties fron the attribute this.title = settings.GetProperty <string>("title"); this.size = new Vector2(settings.GetProperty <float>("width"), settings.GetProperty <float>("height")); this.anchor = settings.GetProperty <StratusGUI.Anchor>("anchor"); this.dimensions = settings.GetProperty <StratusGUI.Dimensions>("dimensions"); // If the size is relative... if (this.dimensions == StratusGUI.Dimensions.Relative) { this.scale = this.size; } // Calcualte the rect this.currentSize = this.CalculateSize(sceneView); this.rect = StratusGUI.CalculateAnchoredPositionOnScreen(this.anchor, this.currentSize, sceneView.position.size); }
//------------------------------------------------------------------------/ // Methods: Private //------------------------------------------------------------------------/ protected override void OnReset() { Type type = GetType(); var settings = AttributeUtility.FindAttribute <LayoutViewDisplayAttributeAttribute>(type); if (settings == null) { throw new MissingReferenceException("Missing [LayoutSceneViewDisplay] attribute declaration for the class '" + type.Name + "'"); } // Read and set the properties fron the attribute this.title = settings.GetProperty <string>("title"); this.size = new Vector2(settings.GetProperty <float>("width"), settings.GetProperty <float>("height")); this.anchor = settings.GetProperty <StratusGUI.Anchor>("anchor"); this.dimensions = settings.GetProperty <StratusGUI.Dimensions>("dimensions"); // If the size is relative... if (this.dimensions == StratusGUI.Dimensions.Relative) { scale = size; } }
protected override void OnInspect() { anchor = (StratusGUI.Anchor)EditorGUILayout.EnumPopup("Anchor", anchor); dimensions = (StratusGUI.Dimensions)EditorGUILayout.EnumPopup("Dimensions", dimensions); switch (dimensions) { case StratusGUI.Dimensions.Relative: EditorGUI.indentLevel++; scale.x = EditorGUILayout.Slider("Horizontal", scale.x, 0f, 1f); scale.y = EditorGUILayout.Slider("Vertical", scale.y, 0f, 1f); EditorGUI.indentLevel--; //scale = EditorGUILayout.Slider("Scale", scale); break; case StratusGUI.Dimensions.Absolute: EditorGUI.indentLevel++; size.x = EditorGUILayout.FloatField("Width", size.x); size.y = EditorGUILayout.FloatField("Height", size.y); EditorGUI.indentLevel--; //size = EditorGUILayout.Vector2Field("Size", size); break; } }
public LayoutViewDisplayAttributeAttribute(string title, float width, float height, StratusGUI.Anchor anchor, StratusGUI.Dimensions dimensions) { this.title = title; this.width = width; this.height = height; this.anchor = anchor; this.dimensions = dimensions; }