Exemplo n.º 1
0
        private void LoadPrefs()
        {
            mode = (GBillboardRenderMode)EditorPrefs.GetInt(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_MODE), 0);
            string targetAssetPath = EditorPrefs.GetString(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_PREFAB), string.Empty);

            target = AssetDatabase.LoadAssetAtPath <GameObject>(targetAssetPath);

            row      = EditorPrefs.GetInt(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_ROW), 4);
            column   = EditorPrefs.GetInt(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_COLUMN), 4);
            cellSize = EditorPrefs.GetInt(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_CELLSIZE), 256);
            float camX = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_CAM_X), 0);
            float camY = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_CAM_Y), -2);
            float camZ = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_CAM_Z), 0);

            cameraOffset = new Vector3(camX, camY, camZ);
            cameraSize   = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_CAM_SIZE), 2);

            atlasMaterial  = GEditorSettings.Instance.billboardTools.atlasMaterial;
            normalMaterial = GEditorSettings.Instance.billboardTools.normalMaterial;

            srcColorProps   = EditorPrefs.GetString(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_SRC_COLOR_PROPS), "_Color");
            desColorProps   = EditorPrefs.GetString(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_DES_COLOR_PROPS), "_Color");
            srcTextureProps = EditorPrefs.GetString(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_SRC_TEX_PROPS), "_MainTex");
            desTextureProps = EditorPrefs.GetString(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_DES_TEX_PROPS), "_MainTex");

            width      = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_WIDTH), 1);
            height     = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_HEIGHT), 2);
            bottom     = EditorPrefs.GetFloat(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_BOTTOM), 0.2f);
            alphaBlend = EditorPrefs.GetBool(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_ALPHA_BLEND), true);
            saveFolder = EditorPrefs.GetString(GEditorCommon.GetProjectRelatedEditorPrefsKey(KEY_BILLBOARDEDITOR, KEY_SAVE_FOLDER), "Assets/");
        }
Exemplo n.º 2
0
        protected override void OnToolbarGUI(Rect r)
        {
            base.OnToolbarGUI(r);

            List <string> buttonLabels = new List <string>()
            {
                "Atlas",
                "Normal",
                "Flipbook",
                "",
                "A"
            };
            List <Rect> buttonRects = EditorGUIUtility.GetFlowLayoutedRects(r, EditorStyles.toolbarButton, 0, 0, buttonLabels);

            for (int i = 0; i < 3; ++i)
            {
                if (GUI.Button(buttonRects[i], buttonLabels[i], EditorStyles.toolbarButton))
                {
                    mode = (GBillboardRenderMode)i;
                    RenderPreview();
                }
                if (i == (int)mode)
                {
                    Color highlightColor = EditorGUIUtility.isProSkin ? new Color(1, 1, 1, 0.1f) : new Color(1, 1, 1, 0.3f);
                    EditorGUI.DrawRect(buttonRects[i], highlightColor);
                }
            }

            if (GUI.Button(buttonRects[4], buttonLabels[4], EditorStyles.toolbarButton))
            {
                alphaBlend = !alphaBlend;
            }
            if (alphaBlend)
            {
                Color highlightColor = EditorGUIUtility.isProSkin ? new Color(1, 1, 1, 0.1f) : new Color(1, 1, 1, 0.3f);
                EditorGUI.DrawRect(buttonRects[4], highlightColor);
            }

            Rect saveButtonRect = new Rect(
                r.max.x - 100 - 2,
                r.min.y,
                100,
                r.height);

            if (GUI.Button(saveButtonRect, "Save", EditorStyles.toolbarButton))
            {
                SaveAssets();
            }
        }
Exemplo n.º 3
0
 private void CopyArgs(GBillboardCreatorArgs args)
 {
     mode            = args.Mode;
     target          = args.Target;
     row             = args.Row;
     column          = args.Column;
     cellSize        = args.CellSize;
     cameraOffset    = args.CameraOffset;
     cameraSize      = args.CameraSize;
     atlasMaterial   = args.AtlasMaterial;
     normalMaterial  = args.NormalMaterial;
     srcColorProps   = args.SrcColorProps;
     desColorProps   = args.DesColorProps;
     srcTextureProps = args.SrcTextureProps;
     desTextureProps = args.DesTextureProps;
     cellIndex       = args.CellIndex;
     vertices        = new List <Vector2>(args.Vertices);
     width           = args.Width;
     height          = args.Height;
     bottom          = args.Bottom;
     tris            = GBillboardCreator.Triangulate(vertices.ToArray());
 }