public bool Init(GameObject _obj, int _indentLevel) { Clear(); indentLevel = _indentLevel; Iso2DObj = _obj.GetComponentInChildren <Iso2DObject>();; return(Iso2DObj != null); }
void update_childIso2D_0() { if (_rc.Iso2Ds != null && _rc.Iso2Ds.Length > 0) { _childIso2D_0 = _rc.Iso2Ds[0]; } }
public static List <Iso2DObject> GetSideListOfTileSelection(params Type[] _types) { List <Iso2DObject> _result = new List <Iso2DObject>(); foreach (GameObject _go in UnityEditor.Selection.gameObjects) { if (_go == null) { continue; } IsoTile _t = _go.GetComponent <IsoTile>(); if (_t == null) { continue; } if (_types[0] == Type.Side_Union) { Iso2DObject _Iso2D = _t.GetSideObject(Type.Side_Union); if (_Iso2D != null) { _result.Add(_Iso2D); } } else { _result.AddRange(_t.GetSideObjects(_types)); } } return(_result); }
void Union_Field(Rect _Rect, string _MSG, Iso2DObject _obj, Color _color) { _Rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.LabelField(_Rect, _MSG); _Rect.y += _Rect.height; CustomEditorGUI.Undo_Iso2DSpriteField(_Rect, _obj.sprr.sprite, Iso2DObject.GetSideListOfTileSelection(Iso2DObject.Type.Side_Union), _color); }
void OnEnable() { if (bPrefab = PrefabUtility.GetPrefabType(target).Equals(PrefabType.Prefab)) { return; } _t = (Iso2DObject)target; }
public Vector3 GetPositionWidthoutOffset() { Iso2DObject iso2D = GetComponent <Iso2DObject>(); if (iso2D != null) { return(iso2D.GetPosition_WithoutFudge()); } return(transform.position); }
public void Update_Attached_Iso2DScale() { foreach (var _attached in _attachedList.childList) { Iso2DObject _Iso2D = _attached.Iso2DObj; if (_Iso2D != null) { _Iso2D.AdjustScale(); } } }
public void Clear_Attachment(bool bCanUndo) { Iso2DObject[] _iso2Ds = transform.GetComponentsInChildren <Iso2DObject>(); for (int i = 0; i < _iso2Ds.Length; ++i) { Iso2DObject _iso2D = _iso2Ds[i]; if (_iso2D != null && _iso2D.IsAttachment) { _iso2D.DestoryGameObject(bCanUndo, false); } } }
public void Update_Attached_Iso2DScale(Iso2DObject _Iso2D, bool bUndoable = false, string undoName = null) { if (_Iso2D != null) { if (bUndoable) { Undo.RecordObject(_Iso2D, undoName); } _Iso2D.UpdateIsometricRotationScale(); if (bUndoable) { Undo.RecordObject(_Iso2D.transform, undoName); } _Iso2D.AdjustScale(); } }
public Iso2DObject[] GetSideObjects(params Iso2DObject.Type[] _types) { if (_types == null || _types.Length == 0) { _types = new Iso2DObject.Type[] { Iso2DObject.Type.Obstacle, Iso2DObject.Type.Overlay, Iso2DObject.Type.Side_Union, Iso2DObject.Type.Side_X, Iso2DObject.Type.Side_Y, Iso2DObject.Type.Side_Z, } } ; Iso2DObject[] results = new Iso2DObject[0]; _attachedList.childList.ForEach(r => { if (r.Iso2DObj != null && ArrayUtility.Contains <Iso2DObject.Type>(_types, r.Iso2DObj._Type)) { ArrayUtility.Add <Iso2DObject>(ref results, r.Iso2DObj); } }); return(results); } void Update() { if (!Application.isEditor || Application.isPlaying || !enabled) { return; } } void OnEnable() { Update_AttachmentList(); } void OnTransformParentChanged() { _bulk = null; } void OnTransformChildrenChanged() { if (autoName.bPostfix_Sprite) { Rename(); } Update_AttachmentList(); }
public void Copycat(Iso2DObject _target, bool bUndoable = true) { SpriteRenderer sprr = GetComponent <SpriteRenderer>(); if (bUndoable) { UnityEditor.Undo.RecordObject(sprr, "IsoTile:Copycat:Sprite"); UnityEditor.Undo.RecordObject(this, "IsoTile:Copycat:CustomTransform"); } sprr.sprite = _target.GetComponent <SpriteRenderer>().sprite; localRotation = _target.localRotation; localScale = _target.localScale; if (coordinates != null) { coordinates.bSnapFree = _target.coordinates.bSnapFree; } UnityEditor.EditorUtility.SetDirty(sprr); }
public void Toggle_Side(bool _bToggle, Iso2DObject.Type _toggleType) { Iso2DObject _obj = GetSideObject(_toggleType); if (_bToggle) { if (_obj == null) { Add_SideObject(IsoMap.GetSidePrefab(_toggleType), "Created : " + _toggleType + " Object"); } } else { if (_obj != null) { _obj.DestoryGameObject(true, true); Update_AttachmentList(); } } }
Iso2DObject Side_Field(Rect _Rect, Iso2DObject.Type _sideType, Color _color, GameObject _prefab) { Iso2DObject _obj = _tile_Inspector.GetSideObject(_sideType); bool _bToggle = _obj != null; _Rect.height = EditorGUIUtility.singleLineHeight; EditorGUI.BeginChangeCheck(); _bToggle = EditorGUI.ToggleLeft(_Rect, _sideType.ToString(), _bToggle); if (EditorGUI.EndChangeCheck()) { for (int i = 0; i < Selection.gameObjects.Length; ++i) { if (Selection.gameObjects[i] == null) { continue; } IsoTile _t = Selection.gameObjects[i].GetComponent <IsoTile>(); if (_t != null && !_t.IsUnionCube()) { _t.Toggle_Side(_bToggle, _sideType); } } } List <Iso2DObject> _lookupList = Iso2DObject.GetSideListOfTileSelection(_sideType); if (_bToggle && _lookupList.Count > 0) { if (_obj == null) { _obj = _tile_Scene.GetSideObject(_sideType); } _Rect.y += _Rect.height; CustomEditorGUI.Undo_Iso2DSpriteField(_Rect, _obj.sprr.sprite, _lookupList, _color); } return(_obj); }
public void Clear() { indentLevel = 0; Iso2DObj = null; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (Event.current.type == EventType.ScrollWheel) { return; } SerializedProperty sp = property.serializedObject.FindProperty(property.propertyPath); if (sp != property) { sp = property; } if (sp.objectReferenceValue == null) { return; } GameObject _target = ((Component)sp.objectReferenceValue).gameObject; IsoTile _thisTile = _target.GetComponent <IsoTile>(); Iso2DObject _iso2D = _target.GetComponent <Iso2DObject>(); SpriteRenderer sprr = _target.GetComponent <SpriteRenderer>(); Color borderColor = Util.CustomEditorGUI.Color_Tile; if (_thisTile == null && _iso2D != null) { switch (_iso2D._Type) { case Iso2DObject.Type.Obstacle: borderColor = Util.CustomEditorGUI.Color_Obstacle; break; case Iso2DObject.Type.Overlay: borderColor = Util.CustomEditorGUI.Color_Overlay; break; case Iso2DObject.Type.Side_Union: case Iso2DObject.Type.Side_X: case Iso2DObject.Type.Side_Y: case Iso2DObject.Type.Side_Z: borderColor = Util.CustomEditorGUI.Color_Tile; break; default: borderColor = Util.CustomEditorGUI.Color_Side; break; } } if (sprr == null) { GUILayout.Label("Empty Bulk", EditorStyles.objectFieldThumb); return; } Rect rect = position; Rect rect_inside = new Rect(rect.xMin + border, rect.yMin + border, rect.width - border * 2, rect.height - border * 2); Rect rect_preview = new Rect(rect_inside.xMin, rect_inside.yMin, cellSize, rect_inside.height); Rect rect_info_name = new Rect(rect_preview.xMax, rect_inside.yMin, rect_inside.width - cellSize - fudgeWidth, rect_inside.height * 0.5f); Rect rect_Fudge = new Rect(rect_info_name.xMax, rect_inside.yMin, fudgeWidth, rect_inside.height * 0.5f - border); Rect rect_info_Sub = new Rect(rect_info_name.xMin, rect_info_name.yMin + cellSize * 0.5f, rect_info_name.width, rect_inside.height - rect_info_name.height); Rect rect_delete = new Rect(rect_inside.xMax - cellSize * 3.3f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height); Rect rect_select_ctlr = new Rect(rect_inside.xMax - cellSize * 2.2f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height); Rect rect_select_go = new Rect(rect_inside.xMax - cellSize * 1.1f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height); bool bControllerable = (_thisTile == null || _thisTile.gameObject != _target.gameObject) || (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <IsoTileBulk>()); EditorGUI.DrawRect(rect, borderColor); EditorGUI.DrawRect(rect_inside, new Color(0.8f, 0.8f, 0.8f)); CustomEditorGUI.DrawSideSprite(rect_preview, _iso2D, false, false); int iLv = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; EditorGUI.LabelField(rect_info_name, _target.name, EditorStyles.boldLabel); float _fTmp = CustomEditorGUI.FloatSlider(rect_Fudge, "Depth", _iso2D.fDepthFudge, -1f, 1f); if (_fTmp != _iso2D.fDepthFudge) { _iso2D.Undo_DepthFudge(_fTmp); } // 서브 인포 출력 //using (new EditorGUILayout.HorizontalScope()) { float _fMinSize = Mathf.Min(rect_info_Sub.width, rect_info_Sub.height); SpriteRenderer[] _sprrList = _target.GetComponentsInChildren <SpriteRenderer>(); for (int i = 0; i < _sprrList.Length; ++i) { if (_sprrList[i].sprite != null && _sprrList[i] != sprr) { Rect _rt = EditorGUI.IndentedRect(rect_info_Sub); _rt.width = _rt.height = _fMinSize; rect_info_Sub.xMin += _fMinSize; // CustomEditorGUI.DrawSideSprite(_rt, _sprrList[i].sprite, ._Type); Util.CustomEditorGUI.DrawSprite(_rt, _sprrList[i].sprite, _sprrList[i].color, true, true); } } } if (bControllerable) { RegularCollider ctlr = _target.transform.parent.GetComponentInParent <RegularCollider>(); if (Selection.activeGameObject == ctlr.gameObject) { ctlr = null; } using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightYellow)) { if (GUI.Button((ctlr != null ? rect_delete : rect_select_ctlr).ReSize(2f, 2f), "Del!")) { _iso2D.DestoryGameObject(true, true); } } if (ctlr != null) { using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightMagenta)) { if (GUI.Button(rect_select_ctlr, "Ctlr")) { Selection.activeGameObject = ctlr.gameObject; } } } using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightMagenta)) { if (GUI.Button(rect_select_go, "Iso2D")) { Selection.activeGameObject = _target.gameObject; } } } EditorGUI.indentLevel = iLv; }
void Inspector_Side() { EditorGUILayout.Separator(); using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("[Side Control]", EditorStyles.boldLabel, GUILayout.MaxWidth(120)); using (new GUIBackgroundColorScope(Util.CustomEditorGUI.Color_LightBlue)) { EditorGUI.BeginChangeCheck(); bool _bUnionMode = 1 == EditorGUILayout.Popup( _tile_Inspector.GetComponent <IsoTile>().IsUnionCube() ? 1 : 0, new string[] { "Side Mode", " Union Mode" }); if (EditorGUI.EndChangeCheck()) { foreach (GameObject _go in Selection.objects) { if (_go == null) { continue; } IsoTile _t = _go.GetComponent <IsoTile>(); if (_t != null && _t.IsUnionCube() != _bUnionMode) { _t.Reset_SideObject(_bUnionMode); } } } } } EditorGUILayout.Separator(); using (new EditorGUILayout.HorizontalScope()) { float fWidth = EditorGUIUtility.currentViewWidth / 3f; Rect _Rect = EditorGUILayout.GetControlRect( new GUILayoutOption[] { GUILayout.Height(fWidth), GUILayout.ExpandWidth(true) }); Rect[] _DescRectDivision; Rect[] _SubRects; if (_tile_Inspector.IsUnionCube()) { Iso2DObject _Union = _tile_Inspector.GetSideObject(Iso2DObject.Type.Side_Union); if (_Union != null) { SpriteRenderer sprr = _Union.sprr; _DescRectDivision = _Rect.Division( new float[] { 0.25f / 8f, 2.75f / 8f, 1 / 8f, 3f / 8f, 1f / 8f }, null); _SubRects = _DescRectDivision[1].Division(null, new float[] { 0.05f, 0.35f, 0.6f }); Union_Field(_SubRects[1], "Union Sprite", _Union, Handles.selectedColor); Util.CustomEditorGUI.DrawSprite(_SubRects[2].Division(new float[] { 0.25f, 0.5f }, null)[1], IsoMap.instance.IsoTile_Union_OutlineImage, Color.clear, true, false); CustomEditorGUI.DrawSideSprite(_DescRectDivision[3], _Union, false, false); } } else { _DescRectDivision = _Rect.Division( new float[] { 0.5f / 8f, 2.5f / 8f, 1f / 8f, 3 / 8f, 1f / 8f }, null); _SubRects = _DescRectDivision[1].Division(null, new float[] { 2 / 10f, 2 / 10f, 2 / 10f, 2 / 10f, 2 / 10f }); _Rect = _DescRectDivision[3].Division(new float[] { 0.1f, 0.8f }, new float[] { 0.2f, 0.8f })[3]; Util.CustomEditorGUI.DrawSprite(_Rect, IsoMap.instance.IsoTile_Side_OutlineImage, Color.clear, false, false); Iso2DObject _Iso2D_x = Side_Field(_SubRects[0], Iso2DObject.Type.Side_X, Handles.xAxisColor, IsoMap.instance.Side_X_Prefab); Iso2DObject _Iso2D_y = Side_Field(_SubRects[2], Iso2DObject.Type.Side_Y, Handles.yAxisColor, IsoMap.instance.Side_Y_Prefab); Iso2DObject _Iso2D_z = Side_Field(_SubRects[4], Iso2DObject.Type.Side_Z, Handles.zAxisColor, IsoMap.instance.Side_Z_Prefab); CustomEditorGUI.DrawSideSprite(_Rect, _Iso2D_y, false, false); CustomEditorGUI.DrawSideSprite(_Rect, _Iso2D_x, false, false); CustomEditorGUI.DrawSideSprite(_Rect, _Iso2D_z, false, false); } } EditorGUILayout.Space(); EditorGUILayout.Space(); }
public static void Drawer(Rect rect, GameObject _target) { IsoTile _thisTile = _target.GetComponent <IsoTile>(); Iso2DObject _iso2D = _target.GetComponent <Iso2DObject>(); SpriteRenderer sprr = _target.GetComponent <SpriteRenderer>(); Color borderColor = Util.CustomEditorGUI.Color_Tile; if (_thisTile == null && _iso2D != null) { borderColor = CustomEditorGUI.Iso2DTypeColor(_iso2D._Type); } Rect rect_inside = new Rect(rect.xMin + border, rect.yMin + border, rect.width - border * 2, rect.height - border * 2); Rect rect_preview = new Rect(rect_inside.xMin, rect_inside.yMin, cellSize, rect_inside.height); Rect rect_info_name = new Rect(rect_preview.xMax, rect_inside.yMin, rect_inside.width - cellSize - fudgeWidth, rect_inside.height * 0.5f); Rect rect_Fudge = new Rect(rect_info_name.xMax, rect_inside.yMin, fudgeWidth, rect_inside.height * 0.5f - border); Rect rect_info_Sub = new Rect(rect_info_name.xMin, rect_info_name.yMin + cellSize * 0.5f, rect_info_name.width, rect_inside.height - rect_info_name.height); Rect[] rect_btns = new Rect[] { new Rect(rect_inside.xMax - cellSize * 1.1f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height), new Rect(rect_inside.xMax - cellSize * 2.2f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height), new Rect(rect_inside.xMax - cellSize * 3.3f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height), new Rect(rect_inside.xMax - cellSize * 4.4f, rect_info_Sub.yMin, cellSize, rect_info_Sub.height) }; bool bControllerable = (_thisTile == null || _thisTile.gameObject != _target.gameObject) || (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent <IsoTileBulk>()); CustomEditorGUI.DrawBordereddRect(rect, borderColor, rect_inside, Color.clear); CustomEditorGUI.DrawSideSprite(rect_preview, _iso2D, false, false); int iLv = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; EditorGUI.LabelField(rect_info_name, _target.name, EditorStyles.boldLabel); if (!IsoMap.instance.bUseIsometricSorting) { var IIsoBasis = _iso2D.GetComponentInParent <IISOBasis>(); var isOnGroundObject = false; if (IIsoBasis != null) { isOnGroundObject = IIsoBasis.IsOnGroundObject(); } else { isOnGroundObject = _iso2D.IsColliderAttachment; } float fOnGroundOffset = IsoMap.fCurrentOnGroundOffset; string msg = isOnGroundObject ? string.Format("Depth({0:0.00})", -fOnGroundOffset) : "Depth"; float _fTmp = CustomEditorGUI.FloatSlider(rect_Fudge, msg, _iso2D.FDepthFudge, -1f, 1f); if (_fTmp != _iso2D.FDepthFudge) { _iso2D.Undo_NewDepthFudge(_fTmp); } } // 서브 인포 출력 //using (new EditorGUILayout.HorizontalScope()) { float _fMinSize = Mathf.Min(rect_info_Sub.width, rect_info_Sub.height); SpriteRenderer[] _sprrList = _target.GetComponentsInChildren <SpriteRenderer>(); for (int i = 0; i < _sprrList.Length; ++i) { if (_sprrList[i].sprite != null && _sprrList[i] != sprr) { Rect _rt = EditorGUI.IndentedRect(rect_info_Sub); _rt.width = _rt.height = _fMinSize; rect_info_Sub.xMin += _fMinSize; // CustomEditorGUI.DrawSideSprite(_rt, _sprrList[i].sprite, ._Type); Util.CustomEditorGUI.DrawSprite(_rt, _sprrList[i].sprite, _sprrList[i].color, true, true); } } } if (bControllerable) { int buttonIndex = 0; CustomEditorGUI.Button(rect_btns[buttonIndex++], true, CustomEditorGUI.Color_LightYellow, "Ping!", () => { EditorGUIUtility.PingObject(_target.gameObject); }); CustomEditorGUI.Button(rect_btns[buttonIndex++], true, CustomEditorGUI.Color_LightGreen, "Iso2D", () => { Selection.activeGameObject = _target.gameObject; }); var ctlr = _target.transform.parent.GetComponentInParent <SubColliderHelper>(); if (Selection.activeGameObject != ctlr.gameObject) { CustomEditorGUI.Button(rect_btns[buttonIndex++], true, CustomEditorGUI.Color_LightGreen, "Ctlr!", () => { Selection.activeGameObject = ctlr.gameObject; }); } CustomEditorGUI.Button(rect_btns[buttonIndex++].ReSize(2f, 2f), true, CustomEditorGUI.Color_LightYellow, "Del!!", () => { _iso2D.DestoryGameObject(true, true); }); } EditorGUI.indentLevel = iLv; }