private bool LoadPointFromProfile(FWallView wall, int idx, int x, int y) { var fn = DemoMenuItems.PointName(x, y); var pt = wall.transform.FindChild(fn); var schema = currentData.walls[idx].schema[x, y]; if (!pt) { schema.state = Data.DataPointState.eNone; return(false); } var pi = pt.gameObject.GetComponent <FPointView>(); schema.state = Data.DataPointState.eProfiled; schema.distort = pi.ViewTrans; schema.easy = pi.ViewParts; return(true); }
private void LoadWallFromProfile(FWallView wall) { var fn = wall.gameObject.name; int idx = DemoMenuItems.FaceName2Index(fn); currentData.walls[idx].Capacity = wall.capacity; // we will fill count latter currentData.walls[idx].Count = 0; for (int x = 0; x < DemoMenuItems.TILE_WIDTH; ++x) { for (int y = 0; y < DemoMenuItems.TILE_HEIGHT; ++y) { currentData.walls[idx].schema[x, y] = new Data.DataPoint(); if (LoadPointFromProfile(wall, idx, x, y)) { ++currentData.walls[idx].Count; } } } }
public override void OnInspectorGUI() { findwall = target as FWallView; // draw use less text var op = GUILayout.Width(300); GUILayout.Box("", op); var cont = "Capacity = max(Capacity,Children Count)"; var nl = "\nIf count < Capacity, Random rest(cap - cnt)."; GUILayout.TextArea(cont + nl , Utils.JfGUIStyle.LABEL_TEXT_STYLE, op); GUILayout.Space(10); // draw count field int capv = EditorGUILayout.IntField("Capacity", findwall.capacity , Utils.JfGUIStyle.LABEL_TEXT_STYLE , GUILayout.ExpandWidth(true)); if (capv != findwall.capacity) { Undo.RecordObject(findwall, "Level Inspector"); findwall.capacity = capv; Undo.FlushUndoRecordObjects(); } GUILayout.Box("", op); // draw point grid & op buttons. System.Func <float, GUILayoutOption> w = GUILayout.Width; var wauto = GUILayout.ExpandWidth(true); var tbtn = EditorStyles.toolbarButton; EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, wauto); var dclr = GUI.color; var hiclr = GetFarColor(dclr); GUI.color = currentMode == EditMode.Point ? hiclr : dclr; if (GUILayout.Button("points", tbtn, w(100))) { currentMode = EditMode.Point; } GUI.color = currentMode == EditMode.Viewable ? hiclr : dclr; if (GUILayout.Button("offset", tbtn, w(100))) { currentMode = EditMode.Viewable; } GUI.color = currentMode == EditMode.Rotation ? hiclr : dclr; if (GUILayout.Button("rotate", tbtn, w(100))) { currentMode = EditMode.Rotation; } GUI.color = currentMode == EditMode.Check ? hiclr : dclr; if (GUILayout.Button("check", tbtn, w(100))) { currentMode = EditMode.Check; } GUI.color = dclr; EditorGUILayout.EndHorizontal(); DrawPoints(); EditorGUILayout.Space(); if (GUILayout.Button("Reset", tbtn, w(200))) { ClearPoints(); } // batch options - trans GUILayout.Box("", op); GUILayout.Label("set children trans option ALL to:"); GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("allFixed")) { BatchApplyOption(ApplyFaceFixed); } if (GUILayout.Button("allFaceCamera")) { BatchApplyOption(ApplyFaceCamera); } if (GUILayout.Button("allRandom")) { BatchApplyOption(ApplyFaceRandom); } GUILayout.EndHorizontal(); // batch option - rotation GUILayout.Box("", op); GUILayout.Label("set children's view option ALL to"); GUILayout.Space(10); GUILayout.BeginHorizontal(); if (GUILayout.Button("ShowMore")) { BatchApplyOption(ApplyShowMore); } if (GUILayout.Button("ShowLess")) { BatchApplyOption(ApplyShowLess); } if (GUILayout.Button("KeepDefault")) { BatchApplyOption(ApplyShowFixed); } GUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); }